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

Hierarchy radgrid edit event help

2 Answers 221 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Yash
Top achievements
Rank 1
Yash asked on 16 Oct 2011, 05:51 PM
Hello,

I need some help here. Here is my situation:

I have a binding list which contains another binding list which I use as data source. below is an example:

Objects:

public class test
{
        public string name { get; set; }
        public BindingList<childs> childlist { get; set; }
}
public class childs
{
        public string childname { get; set; }
}

I populate my radgrid by code. below is a preview:
private void form_Load(object sender, EventArgs e)
 {
            BindingList<test> testlist = new BindingList<test>();
 
            /** I populate my list with data. I wont show this here. After the list is populated: **//
 
            this.raggrid.MasterTemplate.Columns.Clear();
            this.raggrid.MasterTemplate.AutoGenerateColumns = true;
            this.raggrid.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            this.raggrid.MasterTemplate.Columns.Add(new GridViewTextBoxColumn("name", "name"));
 
            GridViewTemplate template = new GridViewTemplate();
            this.raggrid.Templates.Add(template);
            template.Columns.Add(new GridViewTextBoxColumn("name", "childname"));
            template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            GridViewRelation relation = new GridViewRelation(this.raggrid.MasterTemplate, template);
            relation.ChildColumnNames.Add("childlist");
            this.raggrid.Relations.Add(relation);
            this.raggrid.DataSource = testlist;
}

The populating step works fine. But now, when the user edits the detail grid(named template from the code), I must update the binding list accordingly (named testlist from the code). I cannot seem to trigger an event when I edit the child grid. How do I achieve this?

PS: When I update the master template the binding list gets updated automatically as expected, but when I update the template I use as detail, it does not update the biding list.
Thanks,

Yash

2 Answers, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 18 Oct 2011, 02:21 PM
Hello Yash,

In Object-Relational hierarchy mode the inner RadGridView level does not support updates and notifications to the external DataSource. To support this operation, we must create a CurrencyManager instance for every parent row and the result will be slow performance and big memory footprint. To work with data in this scenario, you can update it manually using RowsChanged event:

void radGridView1_RowsChanged(object sender, GridViewCollectionChangedEventArgs e)
{
    if (e.GridViewTemplate == this.radGridView1.Templates[0] && e.NewItems.Count > 0)
    {
        GridViewRowInfo row = e.NewItems[0] as GridViewRowInfo;
        MyObj obj = row.DataBoundItem as MyObj;
        obj.Description = "MyObject Description";
        // other changes to your object...
    }
}

I hope this information is useful. Let me know if you need further assistance.

Greetings,
Julian Benkov
the Telerik team

Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

0
Yash
Top achievements
Rank 1
answered on 18 Oct 2011, 07:10 PM
Thing is I do not get any event triggered for RowsChanged when I edit the detail template. Instead, I used the CellValueChanged event. Thank you.
Tags
GridView
Asked by
Yash
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Yash
Top achievements
Rank 1
Share this question
or