# Product - Sigma Grid 2.0 - Sample

## Save checkbox status in paginal grid

This sample demonstrates using array to keep the status of checkbox in grid.

1. Check some boxes in a one page.
2. Switch to another page and turn back to the original page.
3. Those boxes checked is still there.

Sigma grid could automatically seperate page. Yet for each item on every page, we could use javascrip array together with grid API to store the checked checkbox index.

var myCheckedRecords={}; function example_check(chkbox){ chkbox=Sigma.$(chkbox); if (chkbox.checked){ myCheckedRecords[chkbox.value]=true; }else{ delete myCheckedRecords[chkbox.value]; } } function example_checkAll(chkbox,gid,chk){ chkbox=Sigma.$(chkbox); if (chk!==null && chk!==undefined) { chkbox.checked=chk; } var htd=Sigma.Util.getParentByTagName('td',chkbox); var cellIdx=Sigma.Util.getCellIndex(htd); var checked=chkbox.checked; var rows=Sigma.Grid.getAllRows(gid); for (var i=0,j=rows.length;i<j; i++ ){ var cell=rows[i].cells[cellIdx]; if (cell){ var _chk=cell.getElementsByTagName('input')[0]; _chk.checked=checked; example_check(_chk); } } } function example_checkChecked(grid){ grid=Sigma.$grid(grid); var chkAll=Sigma.$('g1_chk'); var htd=Sigma.Util.getParentByTagName('td',chkAll); var cellIdx=Sigma.Util.getCellIndex(htd); var rows=Sigma.Grid.getAllRows(grid); var cno=0; for (var i=0,j=rows.length;i<j; i++ ){ var cell=rows[i].cells[cellIdx]; if (cell){ var _chk=cell.getElementsByTagName('input')[0]; if (myCheckedRecords[_chk.value]){ _chk.checked=true; cno++; } } } chkAll.checked= cno==rows.length ; }

## Related Links

Demos List - Paging