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
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,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hello Andrew,
yes your impression is correct: the xamdatagrid is bound to a datatable. The datatable is filled by a sql statement. I save the custom layout (A). I change the sql result (remove one column and add two new column). In my app, i load the custom layout (A) and i see it not work.
In fact my sql statement have a pivot statement which produce dynamic columns based on the data. So i can not do what you say: toggling the visibility column.
One thing i notice that;
when the sql statement provide new column (ie added column) from the last result, the Load/Save customization work. But when one column was removed, the save/load customizations doesn't' work anymore.
I look for a way to resolve this issue.