Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1770
Refreshing of field layout not being reflected in the UI
posted

On your API web site it mentions this about when the FieldLayoutInitialized events gets fired.

When a DataRecord is created DataPresenterBase's FieldLayouts collection is searched for an existing FieldLayout whose FieldLayout.Fields match the DataRecord.DataItem's properties. If one is not found then a new FieldLayout is created, in which case the FieldLayoutInitializing and FieldLayoutInitialized events will be raised.

I use this event to modify fields because they are dynamic. So what happens is that if the same number of columns are returned back this event does not fire and the header labels do not get updated. 

I tried clearing the field layout like so ReportDataGrid.FieldLayouts.Clear(); when somebody submits a new query to force the event to fire, which it does but before I query for a new datasource. So essentially it's resetting the field layout of the previous data. 

How can I force the field layout to be re-generated each time regardless?

Parents
No Data
Reply
  • 34810
    Suggested Answer
    Offline posted

    Hello KrisVice,

    Thank you for your post.

    I have been investigating into this issue you are seeing currently, but before I proceed further, I have a couple of questions for you on this matter. In your original description above, you say that you are using the FieldLayoutInitializing/Initialized events to modify the fields in your XamDataGrid because they are dynamic. Is this to say that the data items that you are displaying in the XamDataGrid are of a dynamic type as well? In other words, when a query for a new data source is made, is the data item type changing? If not, I wouldn't expect that the FieldLayout initialization related events would fire, as the data item's properties would return a match, and so a new field layout would not be needed. It sounds like, in your case, the data item is changing though, but when the number of fields to be generated remains the same, the FieldLayout initialization events aren't firing. Is this impression correct? If not, would it be possible for you to please provide some more detail on what exactly is happening when you query for a new data source?

    If the data item remains the same, then the field layouts will not be regenerated by default, because the properties will match, and there will not be a need for a new field layout in the grid. You can force the field layouts to be re-generated by continuing to clear the FieldLayouts collection of your XamDataGrid. This will essentially remove the existing field layouts and create a new one for the newly bound data source of the grid. If you do this just before you query for the new data source, I imagine that this should recreate the fields and allow you to dynamically update the header labels of the fields in your XamDataGrid.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer
    Infragistics Inc.
    www.infragistics.com/support

Children
No Data