iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello,
I'm looking for setting all checkbox values (on my first column - column type checkbox).
I would like to do that client-side and I'm using JavaScript. I found a sample "Using Checkbox combined with client-side programming" :
function selectAll() { // get an instance of the WebGrid var grid = wgGetGridById("WebGrid1"); // collect all checkboxes // get all rows element of the WebGrid var rows = grid.Tables["Categories"].gettbTBElement().rows; // iterate through all rows for (var i=0; i< rows.length; i++) { if (rows[i].type == "Record") { // get the first column of the current row (checkbox) var cell = wgGetCellByPosition(rows[i], 0); cell.childNodes[0].checked = true; } } }
All this function work well except the cell.childNodes[0].checked = true instruction. I get an error "childNodes.0" is null or not an object...
Do you have any ideas ?
Nicolas
The snippet you found is still using previous WebGrid reference. If you are using WebGrid 6 or 7, please use this snippet to achieve the same functionality:
function checkAll() { // get an instance of the WebGrid var grid = ISGetObject('grdObj'); //Header processing var RowHeader = grid.RootTable.GetElement(WG40.COLHEADER, WG40.HTMLTABLE).getElementsByTagName("tr")[0] RowHeader.getElementsByTagName("td")[1].getElementsByTagName('input')[0].checked = true; // collect all checkboxes // get all rows element of the WebGrid var rows = grid.RootTable.GetElement(WG40.BODY, WG40.HTMLTABLE).getElementsByTagName("tr"); // iterate through all rows for (var i = 0; i < rows.length; i++) { if (rows[i].type == "Record") { // get the first column of the current row (checkbox) var cell = grid.GetRowByElement(rows[i]).GetCell(0).CellElement; cell.childNodes[0].checked = true; } }}
I also attached a sample that I used to test the snippet.
Thank you Glenn. It is working now.
Best Regards,
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname