Is there a way I can save/load XamDataGrid Field's labels? For example, if i have a field "Cat ID", and i change the LABEL to "Dog ID", how can i save and load the label. My xamDataGrid is set from a SQL table and all fields are auto generated. I know about LoadCustomizations and SaveCustomizations, but they don't appear to include the "Label", just "Name" of the field.
You are very welcome. Just let me know if you have any further questions regarding this issue.
Wow that was fast, and exactly what I needed. Much easier than my idea. Thanks!
Hi Travis,
I modified your GridLayout class to add a label attribute to the saved xml. When the report is loaded, it reads the label attribute on the fields and assigns it to the Label property on the Field object.
huh. i am providing a sample that allows my user to change the label. can you show me how to save the label and load it? i can only have one file (currently the file exported by SaveCustomizations)...
In this sample, I am binding to sample data. The user loads the field names, selects one from the list and then can type a new label and save it. When restarted, the user can click Load Report to load the customizations (and label hopefully). This all works, but i want to save it as well. The saving is currently working for everything but the labels. Your second idea seems like what I'd need (one file only).
Thanks.
I created a sample and I see the same behavior as you. No labels are being saved. Since this seemed to contradict what we can see in that code sample link you provided, I went and asked the xamDataGrid developers about it. I also checked the source code for that version in the post. Both I and the developers do not see how the label could have been saved in the XML as there is no code for saving it. We are thinking that the label code in that comment was added after the xml was created by SaveCustomizations. Unfortunately this means that SaveCustomizations do not save the labels. The reason for this, as explained by the developers, is that SaveCustomizations was meant to save things that could be changed by the end user. Since the XamDataGrid does not provide any UI for changing the label, the grid does not need to save it.
So in this case, if you need to save the labels it's going to need to be done manually by the developer of the application. The Fields in the FieldLayout can be accessed and the name/label combination can be saved to your own xml or binary file. When you want to load the labels you can take that name/label combination and use the name to find the Field object and then set the Label property accordingly.
Another option could be to take the resulting string from SaveCustomizations and load it into an XmlDocument, then access the field elements and manually add a label attribute. Loading this modified text back into the XamDataGrid won't cause any issues as the label attribute will simply be ignored. After you load the xml though, you can parse it for the labels and set the labels on your fields accordingly.
Does this make sense? Let me know if you have any questions.