Telerik RadGrid - How to disable sorting for a Column?

dev.e.loper picture dev.e.loper · Apr 28, 2009 · Viewed 18.5k times · Source

In their documentation Telerik says that there is a way to disable sorting for specific column by using AllowSorting property. I'm looking at Telerik.Web.UI.GridColumn members and there is no AllowSorting property. There is a Sortable property but its protected and has to be overriden. So what do I use to turn off sorting for specific column?

There is a AllowSorting property on GridBoundColumn but in this case I'm using GridTemplateColumn. Is there a way to turn off sorting on GridTemplateColumn?

Answer

pyrocumulus picture pyrocumulus · Apr 28, 2009

The AllowSorting attribute is available from the source/markup view in Visual Studio. For example (simplified):

    <tr:RadGrid>
    <MasterTableView>
        <Columns>
            <tr:GridBoundColumn DataField="field" HeaderText="Description" 
                 AllowSorting="false" />
        </Columns>
    </MasterTableView>
    </tr:RadGrid>

I don't know if this works for you? I haven't instantiated my grids from the code-behind files yet, so if that's what you are doing, I can't easily help you. But the above works for me.


EDIT:

Ah it was not clear from the original question, that you were using the GridTemplate column. As you are now using the SortExpression-property, doesn't using the same attribute in the markup work for you? So:

    <tr:RadGrid>
    <MasterTableView>
        <Columns>
            <tr:GridTemplateColumn HeaderText="Description" DataField="field" 
                SortExpression="">
                <!-- template here etc. -->
            </tr:GridTemplateColumn>
        </Columns>
    </MasterTableView>
    </tr:RadGrid>