This is a migrated thread and some comments may be shown as answers.

Call Javascript function on Page Size change or Page Index change

3 Answers 728 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bernard
Top achievements
Rank 1
Bernard asked on 25 Jan 2014, 07:17 AM
Hi,

I am trying to call a Javascript function which will trigger a 'loading screen' when user clicks on controls on the RadGrid Pager, which includes changing the page index or page size.

There is no 'OnPageIndexChanging' or 'OnPageSizeChanging' events from RadGrid which would be able to handle these. Is there any way else I can achieve the above?

'OnPageIndexChanged' or 'OnPageSizeChanged' doesn't work as it is only triggered when the grid has finished loading.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 27 Jan 2014, 10:55 AM
Hi Bernard,

A suggestion is that you can subscribe to the OnCommand client event of the grid and check if the command name is Page and PageSize to to accomplish your requirement.

ASPX:
<ClientSettings>
  <ClientEvents OnCommand="OnGridCommand"  />
</ClientSettings>

JS:
<script type="text/javascript">
    function OnGridCommand(sender, args) {     
        if (args.get_commandName() == "Page")
            alert("Page Index Changed");
        else if (args.get_commandName() == "PageSize")
            alert("Page Size Changed");
    }
</script>

Thanks,
Princy
0
Bernard
Top achievements
Rank 1
answered on 29 Jan 2014, 02:33 AM
Thanks, it does work.

I was thinking is there a way we can accomplish this from code-behind as well?

Thanks.
0
Princy
Top achievements
Rank 2
answered on 29 Jan 2014, 06:57 AM
Hi Bernard,

As far as I know its not possible to accomplish this events from the server side. To be familiar with the server and client side events please have a look into the following documentation:
RadGrid Events
Getting Familiar with Client-side API

Thanks,
Princy
Tags
Grid
Asked by
Bernard
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bernard
Top achievements
Rank 1
Share this question
or