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

Column Sorting Problem

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ash
Top achievements
Rank 1
Ash asked on 06 May 2008, 06:24 PM
I have a Radgrid on my page:

<

telerik:RadGrid ID="RadGrid1" OnColumnCreated="RadGrid1_ColumnCreated" runat="server" style="text-align: left" AutoGenerateColumns="False" GridLines="None">

<MasterTableView>

<RowIndicatorColumn Visible="False">

<HeaderStyle Width="20px" />

</RowIndicatorColumn>

<ExpandCollapseColumn Resizable="False" Visible="False">

<HeaderStyle Width="20px" />

</ExpandCollapseColumn>

<EditFormSettings>

<PopUpSettings ScrollBars="None" />

</EditFormSettings>

<Columns>

<telerik:GridBoundColumn DataField="SKU" HeaderText="SKU"

UniqueName="gcolumn1" >

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Description" HeaderText="Description"

UniqueName="gcolumn2" >

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Orig Qty" HeaderText="Orig Qty"

UniqueName="gcolumn3" >

</telerik:GridBoundColumn>

<telerik:GridBoundColumn DataField="Shiped Qty" HeaderText="Shiped Qty"

UniqueName="gcolumn4" >

</telerik:GridBoundColumn>

</Columns>

</MasterTableView>

</telerik:RadGrid>

I want to allow sorting for just my first column. but code is not working.



Protected Sub RadGrid1_ColumnCreated(ByVal sender As Object, ByVal e As GridColumnCreatedEventArgs) Handles RadGrid1.ColumnCreated

If TypeOf e.Column Is GridHyperLinkColumn Then

Dim col As GridHyperLinkColumn = DirectCast(e.Column, GridHyperLinkColumn)

If col.UniqueName = "gcolumn1" Then

col.SortExpression =

True

End If

End If

End Sub

2 Answers, 1 is accepted

Sort by
0
Prangadj
Top achievements
Rank 1
answered on 06 May 2008, 06:41 PM
Ayesha, first, the ColumnCreated event is raised for auto-generated columns only, hence it will not fire in your case. Second, the first column in your grid is GridBoundColumn, not GridHyperLinkColumn. See the column types here. Third, to allow sorting set AllowSorting=true in the RadGrid tag. Last, set AllowSorting=false for all declarative columns but the first and you will be done.

Prangadj
0
Shinu
Top achievements
Rank 2
answered on 07 May 2008, 05:58 AM
Hi Ash,

You can have a look at the following help article to get information on setting sorting for GridHyperLinkColumn.
Sorting for GridHyperLinkColumn/GridTemplateColumn

Shinu.
Tags
Grid
Asked by
Ash
Top achievements
Rank 1
Answers by
Prangadj
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or