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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Custom format Autogenerated columns in Detail Grids

Thread ID:

Created:

Updated:

Platform:

Replies:

125185 Jul 28,2016 09:21 AM UTC Jul 30,2016 05:24 AM UTC WPF 2
loading
Tags: SfDataGrid
sabrina c.
Asked On July 28, 2016 09:21 AM UTC

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





Sowndaiyan Paulpandi [Syncfusion]
Replied On 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


Sowndaiyan Paulpandi [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;