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

Databinding + Sorting + BindingNavigator

2 Answers 166 Views
GridView
This is a migrated thread and some comments may be shown as answers.
shearer
Top achievements
Rank 1
shearer asked on 05 Feb 2008, 02:00 PM
Hello,

I'm using a BindingNavigator and a RadGridView on the same Form with the same BindingSource.

If I change the sorting in the RadGridView it has no effects on the BindingNavigator or the BindingSource sorting.
Going to the next item by clicking on the BindingNavigator will result in jumps in RadGridView

Using the original GridView with the BindingNavigator, they always have the same sorting.

I also tried to use the RadGridView.SortChanged event to set the BindingSource-sorting but the SortChangedEventArgs are always nothing.

Is there a solution or can you give me a hint how to solve this problem?

Thanks
Christian

2 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 06 Feb 2008, 06:08 PM
Hi Christian,

You can handle the CellClick event of RadGridView:

void radGridView1_CellClick(object sender, Telerik.WinControls.UI.GridViewCellEventArgs e)  
{  
    if (sender is GridHeaderCellElement)  
    {  
        RadSortExpressionCollection sorts = this.radGridView1.MasterGridViewTemplate.SortExpressions;  
        string sort = sorts.ToString();  
 
        if (sort != this.orderDetailsBindingSource.Sort)  
        {  
            this.orderDetailsBindingSource.Sort = sort;  
        }  
    }  

I hope this was helpful.

 
Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Declan
Top achievements
Rank 2
answered on 02 Jun 2009, 08:22 AM
To anyone else having difficulty with sorting:

I followed the suggestion above and lost considerable time trying to get it to work as expected. I eventually posted a ticket. The solution is simple and I should have spotted it myself.


"You can do the same thing, as in the forum post, but in the SortChanged event instead of the CellClick event."

private void sortTestRadGridView_SortChanged(object sender, GridViewCollectionChangedEventArgs e)    
{    
    RadSortExpressionCollection sorts = this.sortTestRadGridView.MasterGridViewTemplate.SortExpressions;    
    string sort = sorts.ToString();    
   
    if (sort != this.sortTestBindingSource.Sort)    
    {    
        this.sortTestBindingSource.Sort = sort;    
    }    
}   
 

Thanks Victor ;)
Tags
GridView
Asked by
shearer
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Declan
Top achievements
Rank 2
Share this question
or