jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Show loading gif when grid methods are run
Tagged: grid, gridLoader, jqxGrid ;
This topic contains 10 replies, has 5 voices, and was last updated by Todor 5 years, 10 months ago.
-
Author
-
I have a few methods for manipulating the grid display that take some time, so I’d like to show a loading gif. I’ve attempted to use
$('#grid').jqxGrid('updating');
and it might be the right idea. The problem seems to be however, that the “show” the gif code isn’t triggered until after all grid manipulation takes place.$('#grid').on('click', '.reset', function() { $('.reset .fa-spinner').show(); reset(); }); function reset() { var groups = $.extend({}, $('#grid').jqxGrid('groups')); $.each(groups, function () { $('#grid').jqxGrid('removegroup', this); }); $('#grid').jqxGrid('addgroup', 'salesRegion'); $('#grid').jqxGrid('collapseallgroups'); function timeout() { setTimeout(function() { var isupdating = $('#grid').jqxGrid('updating'); console.log(isupdating); if(isupdating === false) { $('.reset .fa-spinner').hide(); } else { timeout();} }, 10); } timeout(); }
Is there something I’m missing? It seems like the groups are removed before the gif shows, and then it flashes. As soon as I click the link, there is a delay.
Maybe there’s a much better way to do this?
Hello jacobraccuia,
We already have an integrated loader for Grid. Here is the example:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxloader/index.htm#demos/jqxloader/javascript-loader-with-grid.htmBest Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/Thank you Stanislav.
You misunderstand my question, however. How do I trigger this loader to show whenever any methods are invoked on the grid?
Hello jacobraccuia,
You can use the open method of the Loader, in the beginning, of every method.
$('#jqxLoader').jqxLoader('open');
Best Regards,
StanislavjQWidgets Team
http://www.jqwidgets.com/The Grid methods don’t have a callback (that i’m aware of) that will tell me when the method finishes so that I can call
$('#jqxLoader').jqxLoader('close');
I need to know when they finish so I can hide the loader when it’s done!
Hello jacobraccuia,
Use this method:
http://jsfiddle.net/jqwidgets/g7zEL/Best Regards,
Stanislav
jQWidgets Team
http://www.jqwidgets.com/Thank you. At this point we’re kind of just walking in circles, I really appreciate your help, but it’s not what I’m looking for. I definitely now know how to show a loading gif on the site!
I want to know what event I can watch for that triggers when a Grid method is finished running // all grid methods have completed ( filtering, sorting, adding removing columns, etc )
Hi jacobraccuia,
Methods are synchronous
So a method finishes after you call the method. In case you load data dynamically through AJAX, use the bindingcomplete event.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comIf I run 10 of them at once they take over 5 seconds! Such as looping through all of the columns and showing / hiding them. I get that it’s async, but shouldn’t it return a “complete?”
Hi,
I’m used to place the following code in my binding complete event.
$(“#jqxgrid”).jqxLoader(‘close’);
But still now I can able to see the empty table for 1 second in my page after loader closed.Hello Maya,
I would like to suggest you to use
$('#jqxgrid').jqxGrid('showloadelement');
and$('#jqxgrid').jqxGrid('hideloadelement');
instead of jqxLoader.Let us know if you need further assistance.
Best Regards,
TodorjQWidgets Team
https://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.