EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: lorwynz_11 on November 12, 2013, 07:58:58 PM



Title: Get all rows in datadrid
Post by: lorwynz_11 on November 12, 2013, 07:58:58 PM
I have created a grid panel.It has no. of records. I want to get all data in the grid when click a button.This function is working, if select entire row using datagrid('getSelections');

is possible get entire data in the grid without select the rows? and is it possible get the value of first column only for each row?


Title: Re: Get all rows in datadrid
Post by: stworthy on November 12, 2013, 08:17:14 PM
Please call 'getRows' method to get the current page rows.
Code:
var rows = $('#dg').datagrid('getRows');
for(var i=0; i<rows.length; i++){
  console.log(rows[i]['itemid']);
}


Title: Re: Get all rows in datadrid
Post by: lorwynz_11 on November 12, 2013, 08:49:45 PM
is console.log is another way of alert function or it's different? where i could find the result of console.log?


Title: Re: Get all rows in datadrid
Post by: yupengfei on November 14, 2013, 09:00:08 PM
call 'getRows' method to get the current page rows.

if your first column field named  'name' ,  the code for get the value of first column only for each row

var rows  = $("#dg").datagrid('getRows');
$.each(rows, function(i, e){
   console.info(e.name);
});