Hi,
I had a rad grid which gets bound a totally different datasource based on certain events. I have enabled autogenerated columns and this works all fine. I have some logic on the ColumnCreated event to set the visible flag on the column based on some criteria. This is all working fine.
However, i have noticed that if there are columns with the same names, in two different datasources, the autogenerated column property gets cached!
E.g I have DataSource1 and DataSource2. Both contain a column called UserId. When displaying DataSource1 i want to hide that column. I do that by setting the visible property to false. When I switch to datasource2, i do not want to hide this column, but it still hides it (even though the visible property is set to true)! If i switch to a different datasource (i.e datasource3) which does not contain a column of the same name, and then switch back to datasource2, it will display that column....
What I need is some way of letting the RadGrid know that it needs to regenerated all the autogenerated columns, even though they may have the same name.
Or if possible, a way to add a custom prefix to the UniqueName of the autogenerated columns
Below is the code I use to set the visible property:
Thanks,
I had a rad grid which gets bound a totally different datasource based on certain events. I have enabled autogenerated columns and this works all fine. I have some logic on the ColumnCreated event to set the visible flag on the column based on some criteria. This is all working fine.
However, i have noticed that if there are columns with the same names, in two different datasources, the autogenerated column property gets cached!
E.g I have DataSource1 and DataSource2. Both contain a column called UserId. When displaying DataSource1 i want to hide that column. I do that by setting the visible property to false. When I switch to datasource2, i do not want to hide this column, but it still hides it (even though the visible property is set to true)! If i switch to a different datasource (i.e datasource3) which does not contain a column of the same name, and then switch back to datasource2, it will display that column....
What I need is some way of letting the RadGrid know that it needs to regenerated all the autogenerated columns, even though they may have the same name.
Or if possible, a way to add a custom prefix to the UniqueName of the autogenerated columns
Below is the code I use to set the visible property:
void RadGrid1_ColumnCreated(object sender, GridColumnCreatedEventArgs e) |
{ |
if (myAdminTree != null && myAdminTree.SelectedNode != null) |
{ |
string uniqName = e.Column.UniqueName; |
if (myAdminTree.CurrentDataKeyNames.Contains(uniqName)) |
{ |
e.Column.Visible = false; |
} |
} |
} |
Thanks,