EasyUI Forum
April 28, 2024, 03:35:35 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.getSelections is not returning selected rows  (Read 22456 times)
alex.capurro
Newbie
*
Posts: 25


View Profile Email
« on: May 28, 2012, 07:12:52 AM »

Hi,

I have a table that i am creating with code, ie:

Code:
$('#users').datagrid({
title : 'Users',
iconCls : 'icon-user',
width : '100%',
height : 'auto',
nowrap : true,
striped : true,
collapsible : false,
url : "/getUsers",
sortName : 'userId',
loadMsg: 'Loading data form server..',
sortOrder : 'desc',
remoteSort : true,
idField : 'userId',
doSize:true,
fit:true,
columns : [ [ {
title : 'User ID',
field : 'userId',
width : 60,
sortable : true
}, {
field : 'username',
title : 'Username',
width : 90,
rowspan:2,
sortable : true,
sorter : function(a, b) {
return (a > b ? 1 : -1);
}
} , {
field : 'name',
title : 'Name',
width : 350,
rowspan:2,
sortable : true,
sorter : function(a, b) {
return (a > b ? 1 : -1);
}
} ] ],
pagination : true,
rownumbers : true
});

I then have a button that when you click on it calles this function:

Code:
function getSelections(){
var ids = [];
var rows = $('#users').datagrid('getSelections');
for(var i=0;i<rows.length;i++){
ids.push(rows[i].id);
alert(ids[i]);
}
}

However no matter how many rows i select, the rows variable only shows me 1 selection (the last one i choose).

Here is the html of my table:

Code:
<table id="users" maximizable="false" toolbar="#userSearchtb"></table>
Logged
alex.capurro
Newbie
*
Posts: 25


View Profile Email
« Reply #1 on: May 30, 2012, 03:43:44 AM »

Actually i solved the problem. It was because the idField of the table i was using was incorrect.

it appears that the getSelections uses the idField property so you need to make sure that the idField is actually the same as the one passed in the json data.
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!