6 Answers, 1 is accepted
Try the following code snippet to enable Sorting for a column.
CS:
protected void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) |
{ |
if (e.Column is GridBoundColumn) |
{ |
GridBoundColumn col = (GridBoundColumn)e.Column; |
if (col.UniqueName == "Name") |
{ |
col.AllowSorting = true; |
} |
} |
} |
Princy.
Since the ColumnCreated handler will be entered only for autogenerated columns, you can also use the RadGrid1.MasterTableView.RenderColumns collection, to get access to any of the columns in the control.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
As Yavor pointed you can enable sorting for a particular column in the PreRender event as shown below.
CS:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns) |
{ |
if (col.ColumnType == "GridBoundColumn") |
{ |
GridBoundColumn column = (GridBoundColumn)col; |
if (column.UniqueName == "columnUniqueName") |
{ |
column.AllowSorting = true; |
} |
} |
} |
RadGrid1.Rebind(); |
} |
Thanks
Shinu.
Dim sku As DataColumn = New DataColumn("sku")
sku.DataType = System.Type.GetType(
"System.String")
Table1.Columns.Add(sku)
Dim Description As DataColumn = New DataColumn("Description")
Description.DataType = System.Type.GetType(
"System.String")
Table1.Columns.Add(Description)
Dim Quantity As DataColumn = New DataColumn("OrigQty")
Quantity.DataType = System.Type.GetType(
"System.String")
Table1.Columns.Add(Quantity)
Dim ShipedQty As DataColumn = New DataColumn("ShipedQty")
ShipedQty.DataType = System.Type.GetType(
"System.String")
Table1.Columns.Add(ShipedQty)
Dim b As Integer
b = 1
Dim row As DataRow = Table1.NewRow()
Dim a As Integer = 0
While a <= 1
row = Table1.NewRow()
Dim d As Integer
d = a
row.Item(
"sku") = skunum(a)
row.Item("Description") = desc(a)
row.Item("OrigQty") = orig(a)
row.Item("ShipedQty") = ship(a)
Table1.Rows.Add(row)
b = b + 1
a = a + 1
End While
Catch ex As Exception
End Try
Dim ds As New DataSet()
ds =
New DataSet()
ds.Tables.Add(Table1)
RadGrid1.DataSource = ds
RadGrid1.DataBind()
also can you tell me how do i make my first column a hyperlink.
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/Programming/NeedDataSource/DefaultCS.aspx
http://www.telerik.com/help/radcontrols/aspnet%2Dajax/?grdGettingFamiliarWithServerAPI.html
Prangadj