I wanted paging in my datagrid to display a spinner. Here's how I accomplished that:
1) QPaginatorBase
Unfortunately, you have to alter QPaginatorBase in order to change the action config to use the WaitIcon. The way I changed it, if added to core, will still allow it to behave normally until overridden with a child class.
Simply move the "Setup Pagination Events" section of code into its own "Setup" function, and ensure you call it from where the code used to reside.
important: This includes both the __construct() function, as well as the UseAjax portion of __set()
2) QPaginator
Now that the action code is somewhere we can override it safely (before, in the constructor, there was no way to avoid it without also avoiding calling the grandparent constructor, which we needed), let's actually do so.
Create a WaitIcon member of QPaginator, then, overriding Setup(), pass it in as part of the QAjaxControlAction.
You'll also want to tweak the setter for WaitIcon, so that it re-calls Setup, after doing a $this->RemoveAllActions('onclick');
This way, if a WaitIcon is set at a later point, it still gets used on a click.
3) QDataGrid
Now that changing pages can trigger a WaitIcon, let's create one, and display it.
Create a WaitIcon member of QDataGrid, create it in __create, and Render it as part of the Get*HTML functions, wherever you want it to appear. (In my case, it's beside the filter button on my new QFilteredDataGrid, which will be released soon.)
Then, so that the paginator knows about this wait icon, override the __set function in QDataGrid so that when a Paginator, or PaginatorAlternate is set, you set the WaitIcon on it to your WaitIcon.
That's it!
(authored by VexedPanda)
