jQuery EasyUI DataGrid - Getting Selected Row Data
This example demonstrates how to get the selected row data.
The datagrid component includes two methods to retrieve selected row data:
- getSelected: get the first selected row's data; if no row is selected, return null, otherwise return the record.
- getSelections: get all selected rows' data, returning an array of record elements.
Create the DataGrid
Item ID
Product ID
List Price
Unit Cost
Attribute
Stauts
Usage example
Get the selected row data:
var row = $('#tt').datagrid('getSelected');
if (row){
alert('Item ID:'+row.itemid+"\nPrice:"+row.listprice);
}
Get the itemid of all selected rows:
var ids = [];
var rows = $('#tt').datagrid('getSelections');
for(var i=0; i