EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: korenanzo on April 18, 2016, 04:08:01 AM



Title: datagrid-cellediting: goto first?
Post by: korenanzo on April 18, 2016, 04:08:01 AM
Hi,

I'd like to reach the first cell of  current row:

in the same way we have .datagrid('gotoCell', 'right');

something like .datagrid('gotoCell', 'first')

which could be the best way to do it?

thanks,

Ric


Title: Re: datagrid-cellediting: goto first?
Post by: stworthy on April 18, 2016, 09:05:13 AM
Please try this code.
Code:
var field = ...;  // your first field name
var dg = $('#dg');
var cell = dg.datagrid('cell');
dg.datagrid('gotoCell', {
index:cell.index,
field:field
})


Title: Re: datagrid-cellediting: goto first?
Post by: korenanzo on April 18, 2016, 09:14:39 AM
Thank you

anyway it is possible that I don't know the name of the first column, or it may change (the user can hide columns for example...).




Title: Re: datagrid-cellediting: goto first?
Post by: stworthy on April 19, 2016, 02:16:19 AM
You can call the following function to get the first column name.
Code:
function getFirstField(dg){
var fields = dg.datagrid('getColumnFields',false).concat(dg.datagrid('getColumnFields'));
for(var i=0; i<fields.length; i++){
var field = fields[i];
var col = dg.datagrid('getColumnOption', field);
if (!col.hidden){
return field;
}
}
}