Hello again,
My datasource is a collection of objects, with sub-objects. The databinding is OK, but when I click the row header to perform sorting, an exception is raised.
The following code is the same as the one in the Telerik examples under RadGridView->DataBinding (select sub-object datasource)
ArrayList list = new ArrayList(); |
list.Add(new MyObj("1")); |
list.Add(new MyObj("2")); |
list.Add(new MyObj("3")); |
list.Add(new MyObj("4")); |
list.Add(new MyObj("1")); |
radGridView1.GridElement.BeginUpdate(); |
radGridView1.MasterGridViewTemplate.Columns.Add(new GridViewTextBoxColumn("Inner1.TestProp")); |
radGridView1.MasterGridViewTemplate.Columns.Add(new GridViewTextBoxColumn("Inner1.Inner2.TestProp")); |
radGridView1.MasterGridViewTemplate.Columns.Add(new GridViewTextBoxColumn("Inner1.Inner2.Inner1.TestProp")); |
radGridView1.MasterGridViewTemplate.Columns.Add(new GridViewTextBoxColumn("TestProp")); |
radGridView1.GridElement.EndUpdate(false); |
radGridView1.DataSource = list; |
and the MyObj object is defined as:
public class MyObj |
{ |
public string _innerText = ""; |
public MyObj() {} |
public MyObj(string text) |
{ |
_innerText = text; |
} |
public MyObj Inner1 |
{ |
get |
{ |
return new MyObj(this._innerText + "Inner1"); |
} |
} |
public MyObj Inner2 |
{ |
get |
{ |
return new MyObj(this._innerText + "Inner2"); |
} |
} |
public string TestProp |
{ |
get |
{ |
return this._innerText; |
} |
} |
} |
I notice the following:
When I try to sort any column bound to a sub-object (ie. any of the first 3 columns), I get one of the following errors:
"Cannot find the column Inner1.TestProp"
"Cannot find the column Inner1.Inner2.TestProp"
"Cannot find the column Inner1.Inner2.Inner1.TestProp"
The final column sorts OK.
I also noticed that when I run this demo from within Telerik examples, I don't get an exception, but the sorting doesn't work properly for the first 3 columns.
Cheers
Phi