Unexpected master checkbox behavior

Hello, I’m currently using grid 2.0 and am having an issue with the master checkbox for the grid.



I’m using paging, and let’s say I have 20 pages of 25 rows each.



I load my page, and then I view 5 pages of results.



Then I go back to the first page of results, and click the master checkbox.



It seems to select the 5 pages that I’ve viewed, even though I’m currently only viewing page 1.



Is there a way to prevent this? I would think that checking the master checkbox would only select the checkboxes that I’m CURRENTLY viewing.



Please help!



Rachel



By default master_checkbox checks only rendered rows. In case of paging only rows from opened pages are rendered. To check rows only from one visible page with master_checkbox you should modify dhtmlxgrid_filter.js file.
Starting from dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){ you can place following code:

dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){
t.innerHTML=c[0]+""+c[1];
var self=this;
t.firstChild.onclick=function(e){
self._build_m_order();
var j=self._m_order?self._m_order[i]:i;
var val=this.checked?1:0;
var state=self.getStateOfView();
for (var k=state[1]; k<state[2]; k++){
var c=self.cellById(self.getRowId(k),j);
if (c.isCheckbox()) c.setValue(val);
}
(e||event).cancelBubble=true;
}
}



Thanks for the help.

The code you provided seems to have a little bug in it:

dhtmlXGridObject.prototype._in_header_master_checkbox=function(t,i,c){
t.innerHTML=c[0]+""+c[1];
var self=this;
t.firstChild.onclick=function(e){
self._build_m_order();
var j=self._m_order?self._m_order[i]:i;
var val=this.checked?1:0;
var state=self.getStateOfView();
for (var k=state[1]; k<state[2]; k++){
var c=self.cellById(self.getRowId(k);,j);
if (c.isCheckbox()) c.setValue(val);
}
(e||event).cancelBubble=true;
}
}


I don’t think there should be a semicolon after self.getRowId(k);

In any case, it only started working after I removed it.

Thank you for your note. There is bug in our code. Should not be semicolon after self.getRowId(k);