3

I dynamically change columns for a RadGrid, for some data sources I need AutoGenerateColumns for other I don't. But after data binding with AutoGenerateColumns=True I tried to clear Columns list and add new, but old autogenerated columns still there. There is an example on VB.NET of code for adding new column

reportGrid.AutoGenerateColumns = False
reportGrid.Columns.Clear()
Dim column As New GridBoundColumn
column .DataField = "field1"
column .HeaderText = "header1"
reportGrid.Columns.Add(column)

Columns.Clear() doesn't remove autogenerated columns, how can I remove them? Thanks

IgorCh
  • 2,641
  • 5
  • 22
  • 29

2 Answers2

1

link to telerik website

this is the documentation on how to do what you are trying to do.

or check Grid.MasterTableView.AutoGeneratedColums collection.

gashach
  • 420
  • 5
  • 12
1

According to telerik it is not possible to delete a Grid column which is already added in the Grid's Column collection. One suggestion will be to set its Visibile/Display property to false.

http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-removing-column-on-runtime.aspx

Pablo Claus
  • 5,886
  • 3
  • 29
  • 38
  • according to telerik itsself, there is a remove function. http://www.telerik.com/community/forums/silverlight/gridview/radgridview-adding-removing-columns.aspx – gashach Nov 28 '12 at 13:58
  • @Pabloker thank you, it is not appropriate for me to use Visibile/Display property because I can bind lot of different data sources on the page and some of them are autogenerated, maybe it worth to use different RadGrid for those tables. – IgorCh Nov 29 '12 at 07:42
  • @gashach Thank you also, but in the article that you gave describes removing non-autogenerated columns only. – IgorCh Nov 29 '12 at 07:43