EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: pacific202 on October 10, 2011, 08:14:32 PM



Title: endEdit with blur or keypress?
Post by: pacific202 on October 10, 2011, 08:14:32 PM
Is there any way to capture a blur event on a datagrid in order to end the edit mode?  I've tried this but the event is not firing:

Code:
$("datagrid-id").blur(function(event){ alert(event); });

I'm trying to call endEdit whenever the user clicks anywhere outside of the cells being edited. 

Even better would be a keypress event that could capture "esc" and "enter", but I haven't figured out how to attach that event either.


Title: Re: endEdit with blur or keypress?
Post by: stworthy on October 10, 2011, 11:30:59 PM
The best idea would be to handle the mousedown event:
Code:
$(document).bind('mousedown',function(){
  alert('mousedown');
});
// stop event bubbling on the datagrid panel
$('#datagrid-id').datagrid('getPanel').bind('mousedown',function(){
  return false;
});


Title: Re: endEdit with blur or keypress?
Post by: mzeddd on November 01, 2011, 01:30:13 AM
Cute solution (treeGrid in my case) :)

Code:
onClickRow: function(row){
    $('#tg').treeGrid('beginedit', row.id);
    var timer = setTimeout("$('#tg').treeGrid('endEdit', "+row.id+");",3000);
}

Edit operation will be finished in 3 sec. I have only one checkbox that is why 3 sec. is more than enough for me .