I can get the tree list working fine when I use attribute based xml.
<catalog>
<catalogitem id="1" name="test 1"/>
<catalogitem id="2" name="test 2"/>
</catalog>
but the xml I'm getting from a web service is doing this:
<catalog>
<catalogitem>
<id>1</id>
<name>test 1</name>
<catalogitem>
<catalogitem>
<id>2</id>
<name>test 2</name>
<catalogitem>
</catalog>
I have no problem binding the RadGrid to the xml like the latter but I can't seem to figure out how to do it for a treelist.
Also, is there any way to start the parent id as 0 instead of null/empty??
<catalog>
<catalogitem id="1" name="test 1"/>
<catalogitem id="2" name="test 2"/>
</catalog>
but the xml I'm getting from a web service is doing this:
<catalog>
<catalogitem>
<id>1</id>
<name>test 1</name>
<catalogitem>
<catalogitem>
<id>2</id>
<name>test 2</name>
<catalogitem>
</catalog>
I have no problem binding the RadGrid to the xml like the latter but I can't seem to figure out how to do it for a treelist.
Also, is there any way to start the parent id as 0 instead of null/empty??
5 Answers, 1 is accepted
0

Kyle
Top achievements
Rank 1
answered on 19 Dec 2012, 02:28 AM
I'm still stuck. Any ideas? I really don't want to convert the xml that I receive.
0
Hi Kyle,
In order to resolve your issue you could specify the classes that are returned from the web service the correct attributes as shown in the example below. Note that the default attribute value is XmlElement.
Could you please provide more information of what you mean by starting the parent id as 0 instead of null\empty?
All the best,
Antonio Stoilkov
the Telerik team
In order to resolve your issue you could specify the classes that are returned from the web service the correct attributes as shown in the example below. Note that the default attribute value is XmlElement.
public
class
CatalogItem
{
[XmlAttribute]
public
int
Id {
get
;
set
; }
[XmlAttribute]
public
string
Name {
get
;
set
; }
}
Could you please provide more information of what you mean by starting the parent id as 0 instead of null\empty?
All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Kyle
Top achievements
Rank 1
answered on 19 Dec 2012, 08:29 PM
I'm not sure that's going to work for me. My elements are unknown at design time. Once I see the xml I would like to display the tree. I was creating the columns dynamically at runtime.
As for the parentid. My xml is using a guid as the id and parentid fields. The parentid of the top most element in the tree is an empty guid or 00000000-0000-0000-0000-000000000000 but not null or empty string.
As for the parentid. My xml is using a guid as the id and parentid fields. The parentid of the top most element in the tree is an empty guid or 00000000-0000-0000-0000-000000000000 but not null or empty string.
0
Hello Kyle,
Another possible option to alter the XML document is to use transformation files as described below.
Additionally, you could go through the help article below for more information about how it constructs its items.
Note that you could resolve both of your issue by manually parsing the data in custom objects which instead of empty Guid contain null values and the TreeList could be easily data bound to this data.
All the best,
Antonio Stoilkov
the Telerik team
Another possible option to alter the XML document is to use transformation files as described below.
Additionally, you could go through the help article below for more information about how it constructs its items.
Note that you could resolve both of your issue by manually parsing the data in custom objects which instead of empty Guid contain null values and the TreeList could be easily data bound to this data.
All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Kyle
Top achievements
Rank 1
answered on 02 Jan 2013, 04:50 AM
I think I found a good way to do it.
XmlDocument response = request.Send();
XmlReader xmlReader = new XmlNodeReader(response.SelectSingleNode("response/content/readbyquery/collection"));
dsCatalog.ReadXml(xmlReader);
RadGrid1.DataSource = dsCatalog;
This seemed to work well.