This is a migrated thread and some comments may be shown as answers.

Sorting error when datasource is a sub-object collection

1 Answer 152 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phi
Top achievements
Rank 1
Phi asked on 06 Jul 2007, 01:28 AM

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

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 06 Jul 2007, 11:44 AM
Hello Phi,

the fix will be available in Q1 SP2 release. Thank you for the feedback. Your points have been updated.
 

Greetings,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Phi
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or