EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: strikefist on September 17, 2013, 07:17:13 PM



Title: How to get the row index of treegrid
Post by: strikefist on September 17, 2013, 07:17:13 PM
in the API treegrid dependent datagrid, the datagrid has getRowIndex way to get row index. but, in treegrid always used to return -1.
when the Properties rownumbers was set true, how can i get the value of a row number column

(http://www.jeasyui.com/tutorial/tree/images/treegrid2.png)


Title: Re: How to get the row index of treegrid
Post by: stworthy on September 18, 2013, 02:17:19 AM
To get the cell value of row number column, try the code below:
Code:
var tg = $('#tg');
var opts = tg.treegrid('options');
var row = tg.treegrid('find', your_row_id);  // find the row by id
var tr = tg.treegrid('options').finder.getTr(tg[0],row[opts.idField]);
var cell = tr.find('div.datagrid-cell-rownumber');
var value = cell.text();
alert(value);


Title: Re: How to get the row index of treegrid
Post by: strikefist on September 19, 2013, 07:23:42 PM
thank you for your code.When rownumbers is set true,it works well,but rownumbers is set false,it still can not get the row index.would you please help me again?
To get the cell value of row number column, try the code below:
Code:
var tg = $('#tg');
var opts = tg.treegrid('options');
var row = tg.treegrid('find', your_row_id);  // find the row by id
var tr = tg.treegrid('options').finder.getTr(tg[0],row[opts.idField]);
var cell = tr.find('div.datagrid-cell-rownumber');
var value = cell.text();
alert(value);