Hi,
I am new to infragistics.
I use webdatagrid and I want to hide all columns which starts with a particular column name in server side.
I understand that in client sidethe following code can be provided to hide coumns that start with "abc".
I would like to perform the same in server side.
if (webdatagrid1.get_columns().get_column(i).get_key().startsWith("abc"))
{ webdatagrid1.get_columns().get_column(i).set_hidden(true);
}
Your help is much appreciated
Regards
Niranjani Kuber
Hello Niranjani,
Hiding the columns on the server would be very similar to how you hide them on client:
if (webdatagrid1.Columns[i].Key.StartsWith("abc"))
{
webdatagrid.Columns[i].Hidden = true;
However, it is important to note that the server side Columns collection will only contain columns that you have manually created through code/markup. If you have AutoGenerateColumns set to true then this collection will be empty. If you do require AutoGenerateColumns then the recommended approach would be to handle the InitializeRow event of the WebDataGrid in there and then modify the columns:
protected void grid_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e){ if (e.Row.Index == 0) { for (int i = 0; i < e.Row.Items.Count; i++) { if (e.Row.Items[i].Column.Key.StartsWith("abc")) { e.Row.Items[i].Column.Hidden = true; } } }}