EasyUI Forum
September 16, 2025, 01:49:25 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: Question related to select all checkbox on datagrid  (Read 8522 times)
Darrel
Jr. Member
**
Posts: 74


View Profile
« on: October 18, 2016, 07:23:48 AM »

Hello,

I'm stuck in a scenario in the datagrid. There are two scenarios:
1) When I click on the header checkbox, all the records get selected on the page. But when I submit the form, I get no values from the grid since it has not pushed any values into the array.
2) But in the current page, if I independently choose all the checkboxes on the grid one by one, without selecting the header checkbox, then the select all checkbox in the header also get's checked automatically. And when I submit, I get the values due to the onCheck function written during the datagrid initialization.

Code snippet is as follows:

Code:
var checkedRows = [];

function onCheck(index,row)
{
for(var i=0; i<checkedRows.length; i++)
{
if (checkedRows[i].chkBoxVal == row.chkBoxVal)
{
return;
}
}
checkedRows.push(row);
}


function onUncheck(index,row)
{
for(var i=0; i<checkedRows.length; i++)
{
if (checkedRows[i].chkBoxVal == row.chkBoxVal)
{
checkedRows.splice(i,1);
return;
}
}
}

$('#PICKLIST_TABLE').datagrid({
url: ajax_url,
idField:'chkboxVal',
pagination: true,
pagePosition: 'both',
multiSort:true,
rownumbers:true,
striped:true,
selectOnCheck: false,
checkOnSelect: false,
onCheck:onCheck,
onUncheck:onUncheck,
fitColumns: true
});

Is it possible to attach some event/method to the header checkbox of the datagrid, so that I can get all the rows checked in the current page?Huh?
Also is it possible to add the elements in the array whenever the select all check box is ticked. Also if a pagination event occurs to another page, the elements should be added in the array automatically on pagination as well in case of select all checkbox being ticked?Huh?

Regards,
Darrel.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 18, 2016, 08:36:29 PM »

Please attach the 'onCheckAll' and 'onUncheckAll' events. These two events fire when the user check or uncheck all the rows.
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!