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

how to set sort icon programmatically in radgrid?

5 Answers 392 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suresh
Top achievements
Rank 1
Suresh asked on 24 Jul 2008, 03:51 PM
Hi,

 How to set sort icon programmatically in radgrid?

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 24 Jul 2008, 05:28 PM
Hi Suresh,

Could you please explain a little bit what are you trying to achieve? For example - are you binding RadGrid to an already sorted data source and want the sorting indicator to appear on initial load automatically? Is that correct?


Regards,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Suresh
Top achievements
Rank 1
answered on 24 Jul 2008, 06:35 PM
yeah excatlly.

if i apply sort preference through a modal window, i'm sorting the data source programmatically. now i want to indicate the sorted column as well.
0
Dimo
Telerik team
answered on 25 Jul 2008, 11:32 AM
Hello Suresh,

In order to make the sort indicator appear automatically on initial page load, you can use the following approach:


<telerik:RadGrid 
    ID="RadGrid3" 
    runat="server" 
    AllowSorting="true" 
    OnSortCommand="RadGrid3_SortCommand"
    <MasterTableView AllowCustomSorting="true"
        <SortExpressions> 
            <telerik:GridSortExpression FieldName="..." SortOrder="Ascending" /> 
        </SortExpressions> 
    </MasterTableView> 
</telerik:RadGrid> 


In this case RadGrid will not sort the already sorted data and the indicator will appear. The only thing to do more is to set AllowCustomSorting="False" on sort command, so that RadGrid starts sorting:


protected void RadGrid3_SortCommand(object sender, GridSortCommandEventArgs e) 
    RadGrid3.MasterTableView.AllowCustomSorting = false



Greetings,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Suresh
Top achievements
Rank 1
answered on 25 Jul 2008, 04:02 PM
Hi ,

Thanks for your post. It helps me to set the sort column in initial load scenario provided the column and sort order is constant.

but lets look at this scenario,

lets have Column 1 , Column 2  -> what if Column and sort order is dynamic in initial load, how can we set sort icon for that particular column?




0
Dimo
Telerik team
answered on 28 Jul 2008, 06:19 AM
Hello Suresh,

Well, in this case you will have to define the sort expressions programmatically, instead of declaratively:

RadGrid Sort Expressions


Greetings,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Suresh
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Suresh
Top achievements
Rank 1
Share this question
or