jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Show All Columns throws a jQuery error
Tagged: beginupdate, checkChange, checkIndex, endupdate, event, grid, hidecolumn, jQuery, jqxgrid, jqxListBox, ListBox, loop, showcolumn
This topic contains 2 replies, has 2 voices, and was last updated by nja 10 years ago.
-
Author
-
Hey there,
Has anybody run across a problem where triggering the grid show/hide for columns causes a jQuery error?
================
A script on this page may be busy, or it my have stopped responding. you can stop the script now, open the script in the debugger, or let the script continue.script: http://<localhost>/Scripts/jquery-1.10.2.js:643
=========================
// Create jqxButton widget to show all the columns at once. $("#showColumnsButton").jqxButton({ height: '26px', theme: 'office' }); $("#showColumnsButton").on('click', function () { $("#jqxgrid").jqxGrid('beginupdate'); var items = $("#jqxWidget").jqxListBox('getItems'); for (var i = 0; i < items.length; i++) { if (!items[i].checked){ $("#jqxWidget").jqxListBox('checkIndex', i); } } $("#jqxgrid").jqxGrid('endupdate'); });
Which calls:
$("#jqxWidget").on('checkChange', function (event) { $("#jqxgrid").jqxGrid('beginupdate'); if (event.args.checked) { $("#jqxgrid").jqxGrid('showcolumn', event.args.value); } else { $("#jqxgrid").jqxGrid('hidecolumn', event.args.value); } $("#jqxgrid").jqxGrid('endupdate'); });
Hello nja,
This sounds like an “infinite loop” issue, but your code seems fine. However, I do not think you need to call beginupdate and endupdate for single grid operations only (showcolumn/hidecolumn) or where no grid methods are called between them (first code block). Please remove the calls to these and try again. If the issue persists, please share how many times are the checkIndex method and the checkChange event called when you click the button. You can determine this with a simple counter variable and console.log().
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi,
I removed the beginupdate and endupdate and that seems to have fixed it. Sorry, must have copied them in from a different code sample.thanks,
nja -
AuthorPosts
You must be logged in to reply to this topic.