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

How to Custom format Autogenerated columns in Detail Grids

Hi,
I have the following scenario, I have a datasource that is made of several datatables, the datatables are created from custom queries on a database and are put in a dataset, where I create the relations building Master/Detail data.

The Grid and all its content is custom made so I create them at runtime.

When I create the MasterGrid I set
  • AutogenerateColumns = True
  • AutogenerateRelations = True
  • AutogeneratingRelations += MyRelationsGeneratingEventHandler
  • AutogeneratingColumns += MyAutogeneratingColumnsEventHandler

In MyRelationsGeneratingEventHandler, for each child grid generated I set:

  • AutoGenerateColumns = True
  • AutoGenerateRelations = True
  • AutoGeneratingRelations = MyRelationsGeneratingEventHandler
  • AutoGeneratingColumns = MyAutoGeneratingColumnsEventHandler

In the MyRelationsGeneratingEventHandler I also set all properties for the child grids and what is set in this event handler is correct (so for example the Filter Row and the Styles for row, header, alternate row are correct)

However, the MyAutoGeneratingColumnsEventHandler, is executed correctly only on the MasterGrid, and it is executed just one time in a strange way the first time I expand a details grid with no information on the Grid and the ItemsSource.

It is not executed for all columns of the Details grids.

So I presume I have not set the event handler correctly. From here the question.

How can I assign the AutoGeneratingColumns event handler to the details grids when they are generated by the AutoGenerateRelations?
I need to be able to format the columns of the child grids to give them the right format based on the data they are handling.

Or if it is not the right event, which is the right event???

Thank you in advance
Regards
Sabrina





2 Replies

SP Sowndaiyan Paulpandi Syncfusion Team July 30, 2016 05:23 AM UTC

Hi Sabrina 
Thanks for contacting Syncfusion support.

In SfDataGrid, if the
AutoGenerateColumns as true the columns will be generate automatically when we set the ItemSource. The ItemsSource will be set to DetailsViewDataGrid when it expanded, hence the columns will generated when expanding any DetailsViewDataGrid first time. It is the default behavior of SfDataGrid. 
As you said, AutoGeneratingColumns event is the correct event for achieve your requirement like applying the format for the respected column.


Regards,
Sowndaiyan



SP Sowndaiyan Paulpandi Syncfusion Team July 30, 2016 05:24 AM UTC

Hi Sabrina 
Thanks for contacting Syncfusion support.

In SfDataGrid, if the
AutoGenerateColumns as true the columns will be generate automatically when we set the ItemSource. The ItemsSource will be set to DetailsViewDataGrid when it expanded, hence the columns will generated when expanding any DetailsViewDataGrid first time. It is the default behavior of SfDataGrid. 
As you said, AutoGeneratingColumns event is the correct event for achieve your requirement like applying the format for the respected column.


Regards,
Sowndaiyan


Loader.
Live Chat Icon For mobile
Up arrow icon