Hi,
Is there any way to change the field position by code in the field layout?.
The ActualPosition property is read only and changing the Column property has not effect... I guess that the ActualPosition property as priority over the Column property.
Anyone?
Thanks.
Hello sebl,
The FieldCollection object inherits an ObservableCollection<Field>. You can utilize the ObservableCollection's Move() method to accomplish what you are looking for. For example:
grid.FieldLayouts[0].Fields.Move(1, 0);
The two integer parameters are the oldIndex and newIndex, respectively.
For more information, you can see the documentation here.
OK,
This does allow me to change the index of the field, but the property ActualPosition is still the one that seems to be used when displaying the fields.
In the end, all fields remain at their current position.
Actually, I can reproduce this without calling the LoadCustomizations method. I believe this could be a possible issue. I am going to investigate this and follow-up here.
Regards,
Alex.
OK, Thanks. I hope there is some kind of workaround.
What I was saying is that you can reproduce the problem by either changing a column's position by Drag&Drop OR calling LoadCustomizations.
I will create a support case on your behalf and link it to this issue. There is a way around this. The Column, Row properties are not take into consideration if the user has moved,fixed, loaded customizations. That is why you have to call the ClearCustomizations() method. Here is one option that you have:
xamDataGrid1.ClearCustomizations(
CustomizationType.FieldPosition);
FieldCollection fields = xamDataGrid1.FieldLayouts[0].Fields;
fields.Move(0, 3);
Regards,Alex.
Guys,
I am experiencing this issue now.
Here is my scenario:
Launch UI
-Load Default Fields
-Allow user to customize visibility and position of the field via a field selector control
-Call SaveCustomizations and persist this info into data store.
Next time launching UI,
-call LoadCustomizations to apply user settings
-And allow user to reconfigure the view (columns/positions)
With combination of this field selector GUI and user performing drag and drop action on the grid, I am experiencing different behavior when programatically move the columns around.
For me to understand this better,
A.
What is the value of ActualPosition.Column before user perform drag and drop?
Does the actual position gets changed after doing drag and drop?
Does the position of the dragged field get reset to original value when ClearCustomizations(CustomizationType.FieldPosition) gets called? If so it get reset to the position before calling LoadCustomization or position after calling LoadCustomizations?
B.
What is the expected value for Fields.Move oldIndex? Is that the current field index in Fields collection OR it is the Field.ActualPosition.Column OR it is Field.Column
C. What should I do if I want user to do drag and drop to move the columns around and/or use my field selector UI to perform the same.
I guess I need a solution that would work in both the cases where by I can move the columns programmatically irrespective of user performed drag and drop or not.
I would have to debug on this to understand it better, it would save my cycles if anyone had researched on this already.
Thanks for helping out.
Any update on this please?
Also in which release version the fix for the issue "drag/drop or LoadCustomizations causing the Fields.Move to not to work" would be avaialbe
Thanks Guys!
Are they any workaround availabe in current version inorder for me to move the columns in code and save customizations.
In otherwords what are my options to rearrnage the columns from the scratch. Can I remove the FieldLayout and add one?
I try setting Column and Row to achieve the behavior however when saving customization the position information is not retained. It retained only when I do drag and drop.
Or until we have the fix I am not advised to programatically move the columns around?
Please find attached is my use case and advise.
Muthu
This is already submitted as an issue and is in development. I cannot say when it will be resolved.
This is caused because, the XamDataGrid keeps track of the user actions in respect to customizations. When the fields are moved in procedural code, this cannot be reflected anymore.
As I said, we are currently looking for a way to change this.