We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problems using ReadXML for grid styles

I''m trying to use WriteXML() and ReadXML() to copy properties into members of the BaseStylesMap collection of a grid. WriteXML() seems to work fine, and ReadXML() works for some properties, but if there are any properties which use nested tags (e.g. true), there are problems. After reading XML containing any nested properties, the grid either starts replacing headers with red boxes that say "Exception," or just throwing exceptions at various times. Any properties that appear in the XML before a nested property are applied (not that it matters much with the grid broken), but those that appear afterward are not.

4 Replies

AD Administrator Syncfusion Team July 28, 2004 03:23 PM

We are not aware of any problems of this nature. There was an problem reading and writing XML schema in the 2.0.5.0 version of our GridGroupingControl, but that was fixed in 2.0.5.1, and did not relate to GridStyleInfo properties. When you mention Tag I assume you mean an XML tag and not a GridStyleInfo.Tag object. If you are using a custom style.Tag object, then your object would have to implement ISerializable in order for the grid to be able to serialize it as part of a GridStyleInfo. Can you provide a sample project showing the problem you are having?


AH Adam Hill July 29, 2004 05:25 AM

Here is a sample project. StyleDemo_8543.zip


AD Administrator Syncfusion Team July 29, 2004 06:26 AM

Thank you for the sample. I was able to avoid the problem you are seeing in the sample with this code. System.IO.StringReader tr = new System.IO.StringReader(txtXML.Text); System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(tr); GridStyleInfo style = new GridStyleInfo(); style.ReadXml(reader); reader.Close(); gridControl1.BaseStylesMap["Standard"].StyleInfo.ModifyStyle(style, Syncfusion.Styles.StyleModifyType.Override); The GridStyleInfo.ReadXml only sets the properties respresented in the XML, leaving all the other properties of the new style object unset. I think here is an explanation of this problem. In the standard basestyle, this is not acceptable as all properties need to be set here (even if they are only the default settings). Having unset properties in most style objects does not matter since they fall back on some parent style for any unset values. But the standard style is the ultimate parent and hence must be fully populated. The code above avoids this problem by getting the XML set properties into a new style object, and then just overriding the properties in the standard style which were set in the XML. I will discuss this problem with Stefan, the grid architect, to see if he thinks my explanation is correct, and if there is something we can do, or if the standard style will have to be handled as a special case in the manner of the code above.


AD Administrator Syncfusion Team July 29, 2004 07:45 AM

The GridStyleInfo.WriteXml/ReadXml were intended as implementation methods for IXmlSerializable. They were not intended for stand-alone use of directly reading and writing Xml. That is why you had to add the tags to avoid the parsing error. And, it is also why the serialization of the standard style is behaving the way it is.

Loader.
Live Chat Icon For mobile
Up arrow icon