Unplanned
Last Updated: 30 Jun 2020 09:44 by ADMIN
Alain
Created on: 30 Jun 2020 09:41
Category: TreeView
Type: Bug Report
0
RadTreeView: The NodeDataBound event is not firing when binding to a DataTable

How to reproduce:

    DataTable table = new DataTable();
    table.Columns.Add("ParentId", typeof(int));
    table.Columns.Add("ChildId", typeof(int));
    table.Columns.Add("ProductId", typeof(int));
    table.Columns.Add("ProductCode", typeof(string));

    table.Rows.Add(0, 1, 3, "Pr - 01");
    table.Rows.Add(1, 2, 4, "P r- 02");
    table.Rows.Add(1, 3, 5, "Pr - 03");

    this.radTreeView1.DisplayMember = "ProductCode";
    this.radTreeView1.ParentMember = "ParentId"; 
    this.radTreeView1.ChildMember = "ChildId"; 
    this.radTreeView1.ValueMember = "ProductId";
    this.radTreeView1.DataSource = table;

1 comment
ADMIN
Hristo
Posted on: 30 Jun 2020 09:44

Hello,

Workaround: Create a custom node and override its OnDataBoundItemChanged method:

    private void RadForm1_Load(object sender, EventArgs e)
    {
        this.RadTreeView1.CreateNode += RadTreeView1_CreateNode;

        // Bind the tree
    }

    private void RadTreeView1_CreateNode(object sender, CreateTreeNodeEventArgs e)
    {
        e.Node = new MyRadTreeNode();
    }

public class MyRadTreeNode : RadTreeNode
{
    protected override void OnDataBoundItemChanged(object oldItem, object newItem)
    {
        base.OnDataBoundItemChanged(oldItem, newItem);

        // Be notified when setting the data-bound item
    }
}

Regards,
Hristo
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.