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

Hide Sorting Indicator Images

3 Answers 172 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 29 Jul 2008, 05:45 PM
I am trying to solve a display issue with the grid sorting images.  I would like to have them hidden when sorting is activated.  The sorting function itself may remain intact, with the only difference being that no image will display in the header. (the rgsortasc and rgsortdesc)

There seem to be several examples of similar sorting functionality in the forums.  The difference is that I would need mine to be generic enough to capture the uniqueid from the event, rather than manually assigning this value.  There are too many grid columns that to do each one would require unnecessary code replication.

I believe it will start out like this:

        protected void grid_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridHeaderItem) 
            { 
                GridHeaderItem header = (GridHeaderItem)e.Item; 
  
                // Logic to hide the sorting images for all columns firing the event 
            } 
        } 

Any help will be greatly appreciated!
  • ASP.NET version: 3.5
  • OS: Windows XP SP2
  • exact browser version: 6.0.2900.2180
  • exact version of the Telerik product: 2008.1.609.35
  • preferred programming language: C#

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jul 2008, 08:44 AM
Hi Drew,

Try the following code snippet in the PreRender event.

CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
 
        foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) 
        { 
            col.ShowSortIcon = false
        } 
       RadGrid1.Rebind(); 
   } 



Thanks
Shinu.
0
Lakshmi Narayana
Top achievements
Rank 1
answered on 26 Sep 2008, 11:38 PM
Hi,
I have one requirement, data is coming from sp and it will sort based on last name - asc already. i just wanted to show arrow image. how to achieve this.
Next time onwards if i click on any other column, it should be sorted based on column we clicked for sort. Please help me.
0
Dimo
Telerik team
answered on 28 Sep 2008, 03:07 PM
Hello Lakshmi,

I guess you need the following:



<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 in the column header, specified by the sorting expression. The only thing to do more is to set AllowCustomSorting="False" on sort command, so that RadGrid starts sorting again:


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



Best wishes,
Dimo
the Telerik team

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