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

[Solved] Sortdescriptor clears

3 Answers 134 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
syed
Top achievements
Rank 1
syed asked on 07 Oct 2010, 04:16 PM
Hi All,

One of the feature of sorting the telerikgridview as written in the help manuals is as follows:

"By clicking again on the header the sort direction is changed to descending and on the next click the sorting is cleared. The header goes into his normal state and the arrow disappears."

I don't want the sortdescriptor to get clear no matter how many times the user click on the sort column. My application is being developed in MVVM so i can't use the codebehind to track the last column. This is the default behaviour and i really want it to be overridden or configured not to be applied. If a user clicks a column it gets sorted ascendingly on the third click i again want it to be seen ascendingly and the sortdecriptor to preserve itself. The native silverlight grid doesnot remove the sort descriptor on the third time click of the same column

Looking forward urgently!
Thanks

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 08 Oct 2010, 11:58 AM
Hi syed,

You just need to handle the sorting event of RadGridView. Within the event handler you will need to tell the grid that the new state is Ascending instead of None.
This is demosntrated on the code bellow.

public MainPage()
        {
            InitializeComponent();
  
            this.RadGridView1.Sorting += new EventHandler<Telerik.Windows.Controls.GridViewSortingEventArgs>(RadGridView1_Sorting);
        }
  
        void RadGridView1_Sorting(object sender, Telerik.Windows.Controls.GridViewSortingEventArgs e)
        {
            if (e.NewSortingState == Telerik.Windows.Controls.SortingState.None)
            {
                e.NewSortingState = Telerik.Windows.Controls.SortingState.Ascending;
            }
        }


Kind regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
syed
Top achievements
Rank 1
answered on 11 Oct 2010, 10:11 AM
Hi Pavel Pavlov ,
Thanks for the response. As i've mentioned i'm following MVVM so is there anyway i can pass this eventargs to my command written in View Model. I can pass grid as object by the following code
<telerikGridView:RadGridView IsReadOnly="True" ShowGroupPanel="False" Name="RadGridView"
                    IsFilteringAllowed="False"
                                                        SelectionMode="Single"
                    ItemsSource="{Binding GridResults, Mode=TwoWay}" AutoGenerateColumns="False"
                                                        CommandExtension:RadGridSorting.Command="{Binding GridSortingCommand}"
                    CommandExtension:RadGridSorting.CommandParameter="{Binding ElementName=RadGridView}"
                  SelectedResultGridRow,Mode=TwoWay}"
                              
                              
                             >

CommandExtension:RadGridSorting.Command="{Binding GridSortingCommand}"
                    CommandExtension:RadGridSorting.CommandParameter="{Binding ElementName=RadGridView}"
Need to pass the eventargs as command parameter  to follow your advice.

Looking forward
0
Pavel Pavlov
Telerik team
answered on 14 Oct 2010, 09:26 AM
Hi syed,

I am afraid that there is no other way except writing some code in the event handler. I believe this does not harm the MVVM pattern or any other aspect of the application.

Kind regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
syed
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
syed
Top achievements
Rank 1
Share this question
or