I've got an application where users can customize their xamdatagrid field layout and the changes are saved at the end of each session. When a request comes in to add an additional column to the application, I want the new column to be appended to the end of the grid. But when the column ordering has been changed it seems like the new column will be assigned a somewhat random position.
I've tried to resolve this by handling the FieldLayoutInitialized event and iterating over the fields, tracking any fields that weren't in the last saved layout, then going over that subset of fields to move them to the edge of the grid. It doesn't seem to work, either usingthe Fields.Move(...) method or setting a new ActualPosition with my desired column number.
Is there an officially sanctioned way to integrate a new column into a saved layout without upsetting the position of the existing columns?
Hello J. Moran,
Thank you for your post.
I have been investigating into this issue that you are reporting, but as of yet, I have not been able to reproduce this issue that you are seeing. When a Field is added to a XamDataGrid, I would expect that it is always added to the end of the collection of your Fields which would cause it to show up in the grid as the last field. This is the behavior that I am seeing. There is an exception to this, and that is when you set the XamDataGrid.FieldLayoutSettings.AutoArrangeCells property to "Never." With this setting, the fields are still added to the collection in the same order, but you will need to explicitly define where they should show up. You can read more on this in our online documentation article about it, here: http://help.infragistics.com/Help/Doc/WPF/2012.1/CLR4.0/html/xamData_Arranging_Cells_within_the_Record.html. Are you setting this property in your application? Also, would it be possible for you to provide more detail on when exactly your Field is being added to your XamDataGrid?
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 15.2.20152.2038 in Infragistics for WPF 2015.2.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Thanks for providing the sample. I've spent some time trying to identify what's unique about my project that is breaking the intended behavior, but so far I haven't had any luck. If I ever figure it out I'll post here, but for now I'm not going to spend any more time trying to fix this particular annoyance.