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

[Solved] Grid.Rebind() on sort?

4 Answers 256 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Dunbar
Top achievements
Rank 2
Michael Dunbar asked on 05 Aug 2009, 09:48 AM
Hello,

I need to rebind my grid when a sort command is called by the user. I tried the OnSortCommand event but that does not fire server side when a column is sorted by the user. The problem is the page load is called again on sort meaning I need to rebind my grid when this happens.

I am using AJAX and advanced data binding on the grid. Is there anyway to rebind a grid when a sort link is clicked on a grid?

Hope that makes sense.

Thanks,

Michael

4 Answers, 1 is accepted

Sort by
0
Michael Dunbar
Top achievements
Rank 2
answered on 05 Aug 2009, 10:45 AM
Alternatively, is it possible to cancel the postback on sort but still allow the sort to happen? This would also solve the problem.
0
Nikolay Rusev
Telerik team
answered on 10 Aug 2009, 07:02 AM
Hello Michael,

Below link explains RadGrid event sequence:
http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html

You will notice that rebinding of RadGrid will be triggered from certain command. You can find list of this commands on the following link:
http://www.telerik.com/help/aspnet-ajax/grdcommandsthatinvokerebindimplicitly.html

Sort command will trigger Rebind automatically, thus you do not need to perform any additional steps to do this.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Michael Dunbar
Top achievements
Rank 2
answered on 10 Aug 2009, 08:17 AM
Hello Nikolay,

Thanks for the information.

I assure you that when using advanced data binding the sort command does not automatically call the NeedDataSource event, which means you have to manually call Rebind() somehow. I am now dealing with this on a support ticket so will send a working project example via that.

Thanks,

Michael
0
Nikolay Rusev
Telerik team
answered on 10 Aug 2009, 09:48 AM
Hello Michael,

Please find the attached application to this post.
If you run the application in DEBUG mode you will see that after firing Sort command RadGrid triggers NeedDataSource event.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Michael Dunbar
Top achievements
Rank 2
Answers by
Michael Dunbar
Top achievements
Rank 2
Nikolay Rusev
Telerik team
Share this question
or