Hi ,
I want to bind my XML data to Rad grid view.I'm using XmlDataProvider.But data was not displayed in the grid.how can i specify in the grid which xml tag to be bound in grid? i want to achieve this with XAML coding. i dont want to write any code in code behind.Any ideas ?
With regards,
Madhu k
I want to bind my XML data to Rad grid view.I'm using XmlDataProvider.But data was not displayed in the grid.how can i specify in the grid which xml tag to be bound in grid? i want to achieve this with XAML coding. i dont want to write any code in code behind.Any ideas ?
With regards,
Madhu k
3 Answers, 1 is accepted
0
Hello Madhu ,
Running XmlDataProvider demo can be found here:
http://demos.telerik.com/wpf/?GridView/DataSources
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Running XmlDataProvider demo can be found here:
http://demos.telerik.com/wpf/?GridView/DataSources
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Madhu
Top achievements
Rank 1
answered on 09 Jun 2009, 12:22 PM
Hi
I already looked into that demo.But that doesnt addresses my problem.In my XML data i'l be having "n" number of child nodes among which i want to show only a few.I've tried to add the grid columns manually.But how to specify which column to bind to which node in XML data.The XAML mark up what ive used is given below
My Xml Data provider loks like this
<XmlDataProvider x:Key="CEMSource" Source="XML\CEM_example_pubtrans_departure.xml" XPath="ContentExchangeMessage/Content/ContentItems/ContentItem[ContentCategoryName\=\'Departure\']"></XmlDataProvider>
My Grid definition goes like this
<telerik:RadGridView Name="radGridView1" ItemsSource="{Binding Source={StaticResource CEMSource}}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'RouteShortName\'] }" HeaderText="Line"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'To\'] }" HeaderText="Dest"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'MinutesLeftToDeparture\'] }" HeaderText="Avgår"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'Remark\'] }" HeaderText="Remarks"></telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Any ideas ?
With Regards,
Madhu k
I already looked into that demo.But that doesnt addresses my problem.In my XML data i'l be having "n" number of child nodes among which i want to show only a few.I've tried to add the grid columns manually.But how to specify which column to bind to which node in XML data.The XAML mark up what ive used is given below
My Xml Data provider loks like this
<XmlDataProvider x:Key="CEMSource" Source="XML\CEM_example_pubtrans_departure.xml" XPath="ContentExchangeMessage/Content/ContentItems/ContentItem[ContentCategoryName\=\'Departure\']"></XmlDataProvider>
My Grid definition goes like this
<telerik:RadGridView Name="radGridView1" ItemsSource="{Binding Source={StaticResource CEMSource}}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'RouteShortName\'] }" HeaderText="Line"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'To\'] }" HeaderText="Dest"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'MinutesLeftToDeparture\'] }" HeaderText="Avgår"></telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=Attributes/Attribute[@AttributeGroup\=\'PublicTransportDeparture\']/ContentAttribute[@AttributeName\=\'Remark\'] }" HeaderText="Remarks"></telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Any ideas ?
With Regards,
Madhu k
0
Hi Madhu ,
I dug deeper in the issue, and discovered a bug with RadGridView. It will not acknowledge XPath-based bindings, and cells will have blank values. You can work around the bug by specifying a cell template and rebind a ContentControl inside that template like this:
I am attaching a sample project that binds a column in the manner I outlined above.
The good news is we fixed the bug, and the fix will make it in today's internal build. Thanks for the report! I have updated your Telerik points.
Kind regards,
Hristo Deshev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I dug deeper in the issue, and discovered a bug with RadGridView. It will not acknowledge XPath-based bindings, and cells will have blank values. You can work around the bug by specifying a cell template and rebind a ContentControl inside that template like this:
<telerik:RadGridView Visibility="Visible" |
Name="radGridView1" |
AutoGenerateColumns="False" |
ItemsSource="{Binding Source={StaticResource CEMSource}}"> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn |
DataMemberBinding="{Binding XPath=ContentAttribute[@AttributeName\=\'RouteShortName\'] }" |
HeaderText="Line"> |
<telerik:GridViewDataColumn.CellTemplate> |
<DataTemplate> |
<ContentControl Content="{Binding XPath=ContentAttribute[@AttributeName\=\'To\']}"> |
</ContentControl> |
</DataTemplate> |
</telerik:GridViewDataColumn.CellTemplate> |
</telerik:GridViewDataColumn> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
I am attaching a sample project that binds a column in the manner I outlined above.
The good news is we fixed the bug, and the fix will make it in today's internal build. Thanks for the report! I have updated your Telerik points.
Kind regards,
Hristo Deshev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.