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
331
Dynamic Field Creation
posted

I am currently attaching an event handler to the FieldLayoutinitialized event to generate a series of columns dynamically for my grid.  Mainly this has to do with a need to see a set of data related to time and Months over the selected time period are the desired columns.  As you can see the number of Months columns will be dynamic depending on the date range that the user selects. 

When the grid is rendered for the first time, the event gets fired and dynamic columns are generated.  However, when the users (on the same screen) select a different date range, the grid has already been rendered and although rebinding to new rows takes place because of property change notification, the FieldLayoutInitialized event does not get called again so that new month columns can be generated. 

How do I force the grid to re-layout its fields?

- Aaron

  • 69686
    Verified Answer
    posted

    Hello Aaron,

    What you need to do is clear the data source, remove the fieldlayout and bind the XamDataGrid again:

                xamDataGrid1.DataSource = null;

                xamDataGrid1.FieldLayouts.Clear();

                xamDataGrid1.DataSource = source;

    This will force the XamDataGrid to create a new FieldLayout.

    Hope this helps.