3 Answers, 1 is accepted
0
Hi,
Please note that our data engine uses LINQ for all data operations. So for example, when you group on the Country column, something like this will be executed:
var results = customersCollection.GroupBy(customer => customer.Country);
You can bind directly to a collection of XElement however lots of types will be unknown and you will not able to sort, filter and group.
Regards,
Didie
Telerik
Please note that our data engine uses LINQ for all data operations. So for example, when you group on the Country column, something like this will be executed:
var results = customersCollection.GroupBy(customer => customer.Country);
You can bind directly to a collection of XElement however lots of types will be unknown and you will not able to sort, filter and group.
Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Zhang
Top achievements
Rank 1
answered on 31 Dec 2013, 02:10 AM
Finally i find a way to solve it and still use XElement, the way is to define a customized XElement Class like below:
public class MyXElement : XElement
{
public MyXElement(XName name, object content) : base(name, content) { }
public MyXElement(XName name, params object[] content) : base(name, content)
{
ElementDic = new Dictionary<string, string>();
foreach (XElement x in content)
{
ElementDic.Add(x.Name.LocalName, x.Value);
}
}
public Dictionary<string, string> ElementDic { get; set; }
}
Populate data as below:
List<MyXElement> myList = new List<MyXElement>();
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Maria"), new MyXElement("LastName", "Anders"), new MyXElement("IsMarried", true)));
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Ana"), new MyXElement("LastName", "Trujillo"), new MyXElement("IsMarried", true)));
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Antonio"), new MyXElement("LastName", "Moreno"), new MyXElement("IsMarried", true)));
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Thomas"), new MyXElement("LastName", "Hardy"), new MyXElement("IsMarried", false)));
this.rgd1.ItemsSource = myList;
And bind it this way:
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ElementDic[FirstName]}" Header="FirstName" UniqueName="FirstName" />
public class MyXElement : XElement
{
public MyXElement(XName name, object content) : base(name, content) { }
public MyXElement(XName name, params object[] content) : base(name, content)
{
ElementDic = new Dictionary<string, string>();
foreach (XElement x in content)
{
ElementDic.Add(x.Name.LocalName, x.Value);
}
}
public Dictionary<string, string> ElementDic { get; set; }
}
Populate data as below:
List<MyXElement> myList = new List<MyXElement>();
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Maria"), new MyXElement("LastName", "Anders"), new MyXElement("IsMarried", true)));
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Ana"), new MyXElement("LastName", "Trujillo"), new MyXElement("IsMarried", true)));
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Antonio"), new MyXElement("LastName", "Moreno"), new MyXElement("IsMarried", true)));
myList.Add(new MyXElement("Emp", new MyXElement("FirstName", "Thomas"), new MyXElement("LastName", "Hardy"), new MyXElement("IsMarried", false)));
this.rgd1.ItemsSource = myList;
And bind it this way:
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ElementDic[FirstName]}" Header="FirstName" UniqueName="FirstName" />
0
Hi,
Thank you for sharing your solution with the community.
Regards,
Didie
Telerik
Thank you for sharing your solution with the community.
Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>