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

[Solved] OnPageIndexChanging event in RadGrid

1 Answer 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tripati
Top achievements
Rank 1
Tripati asked on 31 Jul 2013, 03:13 PM
Hi Team,

We have a scenario where the entire grid will be editable and the grid will have pagination.

What we are trying to achieve is - Let say user made changes to data on a page 1 and then if user clicks on any other page, we want to show a confirmation dialogue "Do you want to save the changes made..." with Yes - No - Cancel button.
If user selects 'Yes' then data will be saved and navigate to selected page
If user selects 'No' then data will not be saved and navigate to selected page
If user selects 'Cancel' then grid will remain on same page with all the edited data.

I assume if we have OnPageIndexChanging event in RadGrid then it could have been achived, but RadGrid only have OnPageIndexChanged event.

Kindly help on this. We are using Q3, 2011 version.

Regards
Tripati Patro

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 05 Aug 2013, 10:47 AM
Hi Tripati,

In order to accomplish this you can subscribe to the OnCommand client event of the grid and check if the command name is Page. If this requirement is met you can fire a command to apply the changes made by the user. A sample demonstration of this can be observed in the code snippets below:

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

JavaScript:
function OnGridCommand(sender,args) {
            if (args.get_commandName() === "Page") {
                var shouldYouSaveChanges = confirm("Would you like to save the canges");
                if (shouldYouSaveChanges) {
                    sender.get_masterTableView().fireCommand("UpdateEdited", "");
                } else {
                    args.set_cancel(true);
                }
            }
        }

Note that the example uses the JavaScript confirm dialog. You can modify the logic to use a different type of dialog according to your requirements.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Tripati
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or