EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: finzaiko on November 15, 2013, 08:14:09 PM



Title: [SOLVED] Edatagrid request focus field
Post by: finzaiko on November 15, 2013, 08:14:09 PM
I use edatagrid, how to set request focus / current move cursor to next field when I press the enter key

Code:
 $("#dgReceive td[field='code'] input").keypress(function(event) {
            if (event.which == 13) {
                console.log('work!'); //move cursor to next field
            }
        });

I try this one but not work yet.

Thanks and appreciate for any help.


Title: Re: Edatagrid request focus field
Post by: stworthy on November 21, 2013, 01:15:51 AM
Using 'onEdit' event to bind the editor event may be more appropriate.
Code:
$('#dg').edatagrid({
onEdit:function(index){
var ed1 = $(this).edatagrid('getEditor',{index:index,field:'f1'});
var ed2 = $(this).edatagrid('getEditor',{index:index,field:'f2'});
$(ed1.target).keydown(function(e){
if (e.keyCode == 13){
$(ed2.target).focus();
}
});
}
});


Title: Re: Edatagrid request focus field
Post by: finzaiko on November 25, 2013, 02:04:01 AM
Hello stworthy,

Thanks for the quick reply that I like great support this forum,
I've try your code, still not working, I think can not find specified target,
I tried the following http://jsfiddle.net/2UXEM/


Title: Re: Edatagrid request focus field
Post by: stworthy on November 25, 2013, 05:20:29 PM
Please refer to the updated example http://jsfiddle.net/2UXEM/2/.


Title: Re: Edatagrid request focus field
Post by: finzaiko on November 25, 2013, 07:27:56 PM
Thanks again stworthy, its solved