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

AutoGeneratedColumns

Hi
Is there a way to identify after all columns have been generated in an sfDataGrid when using
AutoGenerateColumns="True"
In DataGrid there's an AutoGeneratedColumns event but I don't see a similar thing in sfDataGrid, just an AutoGeneratingColumn...

3 Replies

GT Gnanasownthari Thirugnanam Syncfusion Team January 30, 2017 05:27 AM UTC

Hi Iain, 
 
Thank you for contact Syncfusion support. 
 
We have analyzed your query, In SfDataGrid we have AutoGeneratingColumn event. Using this event we can customize or cancel the auto generate column. 

You can refer the below UG link for more information. 
 
  
Regards, 
Gnanasownthari T. 



IL Iain Lawrie January 30, 2017 05:47 PM UTC

Many thanks for the reply but what I'm trying to do is have an event that fires after all the columns are generated and I can access the column count of the grid. At the minute when I use AutoGeneratingColumn the column count of the grid always returns 0 no matter how many columns have been generated. Maybe I'm doing something wrong - should I be able to get a count of auto generated columns from the AutoGeneratingColumn event?

Ta

Iain


GT Gnanasownthari Thirugnanam Syncfusion Team January 31, 2017 09:10 AM UTC

Hi Iain, 

We have analyzed your query. We regret to inform you that, we can’t get the column count in AutoGenratingColumn event because columns are added in the DataGrid.Columns Collection only  after all columns are generated. We suggest to use separate field to maintain ColumnCount in AutoGenratingColumn event otherwise you can get the column count in ItemsSourceChanged event as like below code example. 
 
this.datagrid.ItemsSourceChanged += Datagrid_ItemsSourceChanged; 
private void Datagrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e) 
{ 
    var sfDataGrid = e.OriginalSender as SfDataGrid; 
    var columnCount = sfDataGrid.Columns.Count; 
 

We have prepared the sample as per your requirement, you can download the same from below mentioned location. 

Sample location. 

Please let us know if you have any further assistance on this. 

Regards, 
Gnanasownthari T. 


Loader.
Live Chat Icon For mobile
Up arrow icon