We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

read out column order and visibility


Hi,

Is there a way to read out the current order that the columns are displayed in the databoundgrid? Is there also a way to see if a particular column is visible or not? Thanks!

1 Reply

HA haneefm Syncfusion Team June 28, 2007 11:40 PM UTC

Hi code1234,

Is there a way to read out the current order that the columns are displayed in the databoundgrid?
>>>>>>>>>>>>>>>>>>>>>>
Yes. You can get the bounded column collection orders by using the Binder.InternalColumn property.

foreach(GridBoundColumn c in gridDataBoundGrid3.Binder.InternalColumns)
{
Console.WriteLine(c.MappingName);
}
Is there also a way to see if a particular column is visible or not?
>>>>>>>>>>>>>>>>>>>>>>
You can try this code.

bool IsColumnVisible = gridDataBoundGrid3.Binder.InternalColumns.Contains("ColumnName");

Rearrange the columns.
>>>>>>>>>>>>>>>>>>>>>
To position the columns in the grid, you can use the Binder.LayoutColumns() method. This method rearranges how the columns should be displayed in the grid. Below is the code snippet.

If columns from datasource are populated as Col1, Col2, Col3, Col4, Col5 then you can modify the order of the columns like...

this.gridDataBoundGrid1.Binder.LayoutColumns(new string[] {"Col1", "Col3", "Col5", "Col2", "Col4"});

You can also move columns in the DataBoundGrid, using the grid.Model.Cols.MoveRange method. See the code below,

// moves column 1 to 3
this.gridDataBoundGrid1.Model.Cols.MoveRange(1, 3);

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon