I have created a CrossTab routine which populates a RadGrid. I always no there will be a "Project" column in the first column, but the rest are generated as crosstabs based on the date criteria.
I need to enable filtering on the Projet column, but remove it programatically from all other columns.
How do I do this?
I tried capturing the column in PreRender and looking for col.AllowFiltering but this doesnt appear to be an option?
Thanks
i
5 Answers, 1 is accepted

Can this snippet from the documentation be adjusted to "hide" a filter text box an image? I am looking to disable the filter text boxes on autogenerated columns (but leave them there in the first column which is always fixed in terms of what it returned). I know I can set the individual columns in design mode to allow filtering...how to do it at run time!?
If TypeOf e.Item Is GridFilteringItem Then
Dim filteringItem As GridFilteringItem = CType(e.Item, GridFilteringItem)
'set dimensions for the filter textbox
Dim box As TextBox = CType(filteringItem("ContactName").Controls(0), TextBox)
box.Width = Unit.Pixel(30)
'set ImageUrl which points to your custom image
Dim image As Image = CType(filteringItem("ContactName").Controls(1), Image)
image.ImageUrl = "<my_image_url>"
End If
End Sub 'RadGrid1_ItemCreated


Thanks. I am now getting:
MESSAGE : Unable to cast object of type 'Telerik.WebControls.GridExpandColumn' to type 'Telerik.WebControls.GridBoundColumn'.\nSOURCE:
Thanks
i
Protected Sub grdDemandCost_By_QTR_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.WebControls.GridColumnCreatedEventArgs) Handles grdDemandCost_By_QTR.ColumnCreated
If Session("ddDemandCost_Project") = "(All)" Then
If Not (e.Column.IsBoundToFieldName("Project")) Then
CType(e.Column, GridBoundColumn).AllowFiltering = False
End If
Else
If Not (e.Column.IsBoundToFieldName("Activity")) Then
CType(e.Column, GridBoundColumn).AllowFiltering = False
End If
End If
End Sub

Not all grid columns are GridBoundColumn! You may need to check if the grid column is GridBoundColumn before casting,
Vlad

Done...thanks. Although I dont undestand why I have an expand column being created in a non-hierarchical grid ;-)
Protected Sub grdDemandCost_By_QTR_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.WebControls.GridColumnCreatedEventArgs) Handles grdDemandCost_By_QTR.ColumnCreated
If TypeOf e.Column Is GridBoundColumn Then
If Session("ddDemandCost_Project") = "(All)" Then
If Not (e.Column.IsBoundToFieldName("Project")) Then
CType(e.Column, GridBoundColumn).AllowFiltering = False
End If
Else
If Not (e.Column.IsBoundToFieldName("Activity")) Then
CType(e.Column, GridBoundColumn).AllowFiltering = False
End If
End If
End If
End Sub