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

Custom Sorting With Advanced Databinding

2 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Albert Shenker asked on 11 Feb 2009, 07:13 PM
I have a grid that implements advanced databinding (ie it used the NeedDataSource event to bind the grid). This grid uses the command item template and has some controls in it. It also uses custom sorting (ie it handles the GridSortCommand). I handle all sorting at the database end of things, which is why I implement Custom Sorting. Everything works fine, except I have noticed that the NeedDataSource event fires before the GridSortCommand Event. This causes my datagrid to rebind, then I handle the sort event and specify the sort parameters and rebind the grid. So, the grid essentially binds twice which is not efficient. The reason I brought up the CommandItemTemplate, is that I noticed that when the grid ItemCommand event occurs, the NeedDataSource event never fires unless I explicitly call Grid.Rebind(). This second event sequence makes sense to me and I am able to create the custom binding parameters prior to rebinding the grid.

However, in the sort scenario, this does not work. My basic question is... how do I get custom sorting to work properly with advanced databainding. I am sure there is some good reason to have the NeedDatSource event automatically fire prior to sorting in a built-in sorting scenario. However, with custom sorting, this causes problems.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 12 Feb 2009, 07:38 AM
Hi Albert,

The help document link below  on "Event sequence"  might  throw some light on your problem.
http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html

Thanks,
Princy




0
Albert Shenker
Top achievements
Rank 1
Veteran
answered on 12 Feb 2009, 08:30 AM
I found the problem. It turns out my Item_Command handler had a superfluous rebind statement. Thanks for your help!
Tags
Grid
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Answers by
Princy
Top achievements
Rank 1
Albert Shenker
Top achievements
Rank 1
Veteran
Share this question
or