jQuery UI Widgets › Forums › Grid › Remove sorting and filtering applied on columns at once
Tagged: filter, grid, hidden column, hidecolumn, jqxGrid ;, remove, remove sort and filtering, showcolumn, sort
This topic contains 19 replies, has 6 voices, and was last updated by anichifor3pg 1 year, 6 months ago.
-
Author
-
Hi, I have the same issue and I need a suggestion how to solve it. I’m using jQWidgets 16.0.0 with server side filtering, sorting and pagination and I have the following code:
let initialGridState = null; let resetSortFlag = false; function resetGridState() { resetSortFlag = true; $('#grid').jqxGrid('loadstate', initialGridState); } $("#grid").on("bindingcomplete", function () { if (initialGridState === null) { initialGridState = $("#grid").jqxGrid("savestate"); } if (resetSortFlag) { resetSortFlag = false; $('#grid').jqxGrid('removesort'); } });
Things that I tried:
1. I had removesort in the resetGridState function and I was receiving the bindingcomplete error
2. I created the resetSortFlag variable and moved removesort to the bindingcomplete trigger and I still receive the same error, even though removesort is called from the event trigger, as suggested in the error message.
3. I tried your suggestion above and replaced removesort with$('#grid').jqxGrid({ source: dataAdapter });
unfortunately this doesn’t remove the sorting, it just stays the same.Hi anichifor3pg,
Thank you for the feedback! You can avoid this issue by setting “async: false” to the sourve object. For example:
var source = { async: false, datatype: "json", url: muURL, ..... }
Then, you can rewrite your functions in the following way:
$("#jqxGrid").on("bindingcomplete", function () { if (initialGridState === null) { initialGridState = $("#jqxGrid").jqxGrid("savestate"); } }); function resetGridState() { $('#jqxGrid').jqxGrid('loadstate', initialGridState); $("#jqxGrid").jqxGrid("removesort"); }
Best Regards,
Ivan PeevskijQWidgets team
http://www.jqwidgets.com/Hi Ivan,
I added async false to the source and the error still appears.
I noticed that if I remove the loadstate step, the removesort method removes all sorts when async is true and it only removes the last sort when async is false. Even if I call the method multiple times, it does not remove the other sorts.
The error still shows up in the console in all the cases above.Thank you,
AnaHi Ana,
removesort removes all sort columns in the Grid. As my collague suggested, the bindingcomplete can be used to save the initial Grid state, but I suggest you to remove the
if (resetSortFlag) { resetSortFlag = false; $('#grid').jqxGrid('removesort'); }
as this may lead to errors.
Hi, regardless of where I put the removesort call (either in the bindingcomplete event or outside it), I get the bindingcomplete error. Changing the async property doesn’t affect that, it just seems to introduce more issues, as I mentioned above (it only removes the last applied sort, and has no effect on older ones).
-
AuthorPosts
You must be logged in to reply to this topic.