Hierarchy radgrid edit event help

3 posts, 1 answers
  1. Yash
    Yash avatar
    3 posts
    Member since:
    Oct 2011

    Posted 16 Oct 2011 Link to this post


    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:


    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.AutoGenerateColumns = true;
                this.raggrid.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                this.raggrid.MasterTemplate.Columns.Add(new GridViewTextBoxColumn("name", "name"));
                GridViewTemplate template = new GridViewTemplate();
                template.Columns.Add(new GridViewTextBoxColumn("name", "childname"));
                template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                GridViewRelation relation = new GridViewRelation(this.raggrid.MasterTemplate, template);
                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.

  2. Answer
    Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 18 Oct 2011 Link to this post

    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.

    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.

  3. Yash
    Yash avatar
    3 posts
    Member since:
    Oct 2011

    Posted 18 Oct 2011 Link to this post

    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.
Back to Top