[英]jQuery EasyUI dataGrid save when enter pressed
I have a EasyUI propertyGrid (which inherits dataGrid) with a few rows. 我有一个带有几行的EasyUI propertyGrid(继承了dataGrid)。 I need that when user is editing a text field, when enter is pressed, editing is finished and onAfterEdit is called.
我需要当用户正在编辑文本字段时,在按Enter键时,编辑完成,并调用onAfterEdit。 EasyUI does not do this by default!
EasyUI默认不执行此操作! Any solution?
有什么办法吗?
I had the same problem with treegrid, so i think you can use this code with propertyGrid also: 我在treegrid上遇到了同样的问题,所以我认为您也可以在propertyGrid中使用此代码:
onDblClickRow: function(row){
if (editingId != undefined){
$('#arbol_eui').treegrid('select', editingId);
return;
}
if (row){
editingId = row.id;
pos = row.id;
$('#arbol_eui').treegrid('beginEdit', editingId);
}
var ed = $(this).treegrid('getEditor',
{index:editingId,field:'peso'});
$(ed.target).focus().select().bind('keyup', function(e)
{
var code = e.keyCode || e.which;
if(code == 13) { //Enter keycode
//Trigger code to save row
//This executes onAfterEdit event code
var t = $('#arbol_eui'); //My treegrid selector
t.treegrid('endEdit', editingId);
editingId = undefined; //editingId is a global var
}
});
},
The key is to bind jquery event 'keyup' to the textbox editor for the cell at the 'onDblClickRow' event that also starts editing the row 关键是将'onDblClickRow'事件的单元格的jquery事件'keyup'绑定到该单元的文本框编辑器,该事件也将开始编辑行
Good luck 祝好运
尝试使用datagrid-cellediting扩展,它会添加一些类似的功能
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.