EasyUI Forum
November 30, 2025, 03:50:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: datagrid-cellediting: goto first?  (Read 8451 times)
korenanzo
Guest
« 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
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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
})
Logged
korenanzo
Guest
« Reply #2 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...).


Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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;
}
}
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!