Hello,
I am using an ultragrid in my application. I am also allowing the end users to change column width, cell font name, font size, horizontal alignment, vertical alignment, column caption etc.
Right now, I am saving all these settings in the format of string for each column (like key-value pairs) but as the number of columns are getting increased, it is becoming quite difficult to implement more and manage.
I am looking at better ways and found that SQL Server has XML datatype and Grid has methods like SaveToXML() and LoadFromXML(). If I use this way, If I use SaveToXML() will it save all the settings (apperance settings) which I discussed above or only a part of it.
Let me know whether this works in my case or not and also I appreciate if there are any better ways.
Thanks
Nagarjun.
Hi Nagarjun,
nag4054 said: Is there any example relating to it in KB?
Is there any example relating to it in KB?
I'm sure there are samples included with NetAdvantage that save and load the grid's layout. I'm not sure if there is a KB article, though. Saving and loading the layout is really very simple, you just create a MemoryStream in this case and use the grid.DisplayLayout.Save/Load methods on it.
Saving that stream to a database field can be a bit tricky. And there is a KB article on how to do that:
HOWTO:How can I save a stream to a database?
nag4054 said:What is the easiest way to read the settings for a particular column so that I can display their current settings on the option form.
Assuming that your code is applying the colors, fonts, etc. using the column.CellAppearance, then yes, the easiest way to get this information is to load the layout and examine the properties on the appropriate column.
Also note that you can create a variable of type UltraGridLayout and use the load method of that variable to load the stream data, thus loading the layout into memory without affecting the on-screen grid. This makes it possible for you to examine the properties which are stored in the stream in case you want to show the users some kind of preview of what's in a particular layout. When you want to copy the loaded layout variable into the grid, you use the grid.DisplayLayout.CopyFrom method.
I have one quick question.
I am showing users an option form which contains various options to change for the grid columns like how we see in an excel sheet.
like showing them horizontal align, vertical align,font name,font size, fixed, decimal places etc.
As now, I am reading these settings for the grid by saving as xml and loading from xml datatype,
What is the easiest way to read the settings for a particular column so that I can display their current settings on the option form.
I know reading the appearance object of the column will work but I just want to confirm whether there are any better ways to do it.
Hope I make the question clear.
Nagarjun
Yes, that is exactly what the SaveAsXml/LoadFromXml methods were designed for.