(This may be related to http://ko.infragistics.com/community/forums/p/56268/296411.aspx but I need a solution.)
Hi,
we have a XamDataGrid with dynamically added columns (the column definition is served by the back end and may vary). When the column definition changes it's ok when the layout is not applied. But the saved layout must be loaded when the column definition has not changed.
The columns are added like this (simplified):
UnboundField field = new UnboundField(); field.Name = "colname"; field.Label = "col display name"; field.BindingPath = new PropertyPath(bindingPath); grid.DefaultFieldLayout.Fields.Add(field);
Adding the columns takes place after the control has been initialized and works great - no issues there.
Now after adding the columns I run the LoadCustomizations with a settings string that contains the grids layout with the exact same field list including the dynamic columns from a previous front-end session - but unfortunately the settings do not apply!
this.BookingsGrid.LoadCustomizations(this.bookingsGridCurrentSettings);
The strange thing is that when I run the same settings via a command (in application menu), the settings are applied - the difference there is, that I have to run it in the Loaded-event of the grid to apply. The loaded event then is fired because the parent control is doing some refreshing.
Any suggestions?
As a workaround I guess it'd be also possible to move the LoadCustomizations to the loaded event but it doesn't fire. What is the best way to force the reload of the control?
----
Edit: Using Version 11.2.20112.2125And I just checked again - the settings string is exactly the same for the manually triggered layout loading compared to the LoadCustomizations after setting the dynamic columns.
Hello,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
Ha, resolved the issue:
After removing the Binding="{Binding}" from an UnboundField in the field layout it works and the {} does not appear in the fieldList any more. (Admittedly I don't even remember why I put it there, maybe I thought I needed it to bind data in the template which is not the case.)
I'd consider this a bug anyway since binding the field to its own DataContext should not change anything.
ok, that's what I said :-)
Could you please go through these questions with the developers because I believe the issue may be solvable when we understand what exactly is the problem. The thing is that the layout can be loaded without data when there is no UnboundField - to try that just comment out the UnboundField in my sample.
If all these questions do not show the way to success my solution will be to check for data when loading the layout and to add and remove one data item just in order to being able to load the layout. But please check with the devs of XamDataGrid to resolve the issue since I believe the solution may be simple.
Thank you.
(btw: the formatting in this forum sucks! numbered lists are only displayed in edit mode!)
I have been looking into the updated sample and I can say that the FieldLayout could be applied only if there is data loaded in the XamDataGrid.
thanks for the effort of creating a sample!
It helped me to find that I've been on the wrong path with the dynamic columns.The problem seems not to be related to dynamic columns but to some property of the fieldLayout in the saved data.
I updated the sample with another unbound field where the template is bound to the data item.
When saving the layout with data now two sets of fieldLayouts are saved with two different fieldLists:fieldList="Close;Int32, Test;String;unbound;{}, Open;Int32"fieldList="Close;Int32, Test;String;unbound, Open;Int32"
I don't know what the ";{}" is supposed to mean, but I suspect that the layout is not loaded in xamDataGrid1_Initialized because the fieldList does not match. Only after loading data the fieldlayout is loaded correctly.
So the question is: How can the layout be loaded before the grid contains any data or what must be modified in the field definition in order to stay the same with and without data?
Attached you can find my updated sample.
Thanks!