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
715
Field Chooser, Save customization and dynamic columns
posted

Hello,

i use a xamDataGrid with a SQL Data Binding to the DataSource and the autoGenerateFields is set to true.

In my application, the end user can save the layout of the xamdatagrid with the Savecustomization method. It work very fine but when the underlying SQL statement change (ie. add column or remove column), the loadCustomization don't work anymore.

How i can handle this in order to persist the layout?

Helps will be appreciated,

Thanks,

Pierre

Parents
No Data
Reply
  • 34810
    Offline posted

    Hello Pierre,

    Thank you for your post.

    While I am not extremely familiar with SQL operations when data binding, I imagine that since the XamDataGrid requires some sort of IEnumerable to bind to in order to display data, you are querying your data base and then loading the data into a data table or collection of some sort, which is then bound to the XamDataGrid. Then, you are saving the layout customizations, and changing the underlying SQL statements. Please let me know if this is incorrect, as my following response goes off of this impression.

    When you save the customizations of a XamDataGrid, you essentially save the fields that currently exist in the grid, and when you try loading the customizations, the resultant content of the file that is being loaded needs to match these fields. If a field has been completely removed, or one is added, the customizations will not be loaded, as the field collection differs from the one in the file or stream that you saved to. Also, you will want to check if the FieldLayout that you have when you save your customizations is the same one as the one when you are going to load your customizations as well. You can do this by hooking the FieldLayoutInitialized event of the XamDataGrid before you change the underlying SQL statement. If this event fires, you are getting a new FieldLayout, and the customizations will not load correctly.

    One thing that the save and load customizations does take into effect is whether or not a field is visible or hidden. So, if you would like to continue using the SaveCustomizations and LoadCustomizations methods of the XamDataGrid, you may want to consider toggling the Visibility of the columns that you wish to show in the grid, rather than removing or adding them by modifying the underlying SQL statement.

    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