EasyUI Forum
May 16, 2024, 08:06:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Getting row data for a particular index  (Read 11525 times)
tomhj
Newbie
*
Posts: 40


View Profile
« on: July 16, 2012, 01:38:26 PM »

Perhaps I'm overlooking it, but I don't see a way to get the data for a row in a datagrid based on it's index.  getSelected()  and getSelections() returns the row data for the selected row (or rows) and I see the getData() function - but I dont see a getData(index) method.

Is there a way to get that?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 16, 2012, 03:23:01 PM »

To get a particular index row, please call getRows method.
var rows = $('#dg').datagrid('getRows');
var row = rows[index];
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #2 on: July 16, 2012, 05:18:13 PM »

Does that work even if the data is paginated?   Not sure if the first row on each page restarts at index=0.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: July 16, 2012, 08:47:36 PM »

The 'getRows' method return the current page rows. The first row index of each page is 0, the second row index is 1, etc.
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #4 on: July 17, 2012, 09:18:26 AM »

Great - added the following to my code; works well.

Perhaps this would make a nice addition to the library?

$.extend($.fn.datagrid.methods, {
       getDataForIndex: function(target, index){
           var rows = $(target).datagrid('getRows');
             return rows[index];
             }
});

Thanks
Logged
Radikal
Newbie
*
Posts: 1


View Profile
« Reply #5 on: August 26, 2013, 09:36:07 AM »

Code:
var row = $('#dg').datagrid("getRows")[index];
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!