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
2030
XamDatagrid: Restore customizations with a changed fieldlayout
posted

Hello,

I am using XamDatagrid where most of the columns are created dynamically. These columns are used to show the workload of a ressource per day. I also save the settings (visible columns, field width) by using this.mygrid.SaveCustomizations().

The user can define if he wants to see 2 or 10 weeks. In the case of a change of the number of weeks the XamDatagrid is created with a different set of columns than the saved customizations. In this case the customizations are not loaded at all.

I have seen this approach:

https://klausnji.wordpress.com/2014/04/08/infragistics-xamdatagrid-incorrectly-loading-and-saving-field-layout-when-model-changes/

Is there a solution from Infragistics out of the box as well?

Thanks

Niko

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello Niko,

    I have been investigating into this behavior you are reporting, and allow me to say that this behavior is actually expected - it is the way that the XamDataGrid carries out its customization loading. When loading customizations to the grid, the expectation is that at least the same Fields that you originally saved exist in the grid by Name.

    What this means is that if you save a XamDataGrid with 6 Fields and then try to load into a grid with 2 of those 6 Fields, the customizations will fail to load, as we cannot make the assumption to know what to do with the other 4 Fields. However, if you were to save a grid with 2 Fields and then try to load into a grid with 6 Fields where the original 2 Fields exist by name, the customizations would be loaded successfully. This is expected, and by design of the XamDataGrid, and I am attaching a sample project where you can see this behavior for yourself by modifying the Field widths in the UI along with the int columnCount variable in the code-behind.

    There does not currently exist a workaround to this behavior built into the product. As such, the best thing that I can recommend in this case is that in order to load your customizations, that you save the number of your Fields to an external xml or text file than the one that you are currently saving the customizations to. Alternatively, you can parse the existing one when you go to load it. You would then need to add Fields accordingly such that at least the number and names of the Fields that you saved exist in the grid prior to trying to load the customizations.

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

    XDGCustomizationsCase.zip

Children