如何关联/检索Ext.NET中每个TreePanel节点的自定义数据



我想为我的TreePanel中的每个节点关联自定义数据。然后我将在客户端使用它。

服务器端看起来像:

        Ext.Net.Node root = new Node {Text = "Dummy Form"};
        root.AttributesObject = new { nodeType = "Form" };
        Ext.Net.Node section01 = new Node { Text = "Section 01" };
        section01.AttributesObject = new { nodeType = "Section" };

我如何在客户端访问这个AttributesObject ?

客户端看起来像:

    .Listeners(l =>
    {
       l.ItemClick.Handler = "myClickHandler(item,record,node,index,e)";
    }

我尝试了以下方法:

  • item.nodeType
  • record.nodeType
  • node.nodeType
  • record.data.nodeType

以上都不适合我,每个都返回"undefined"

record.raw。[attributeFieldName]可用于访问客户端数据

对于定义如下的单击处理程序:

.Listeners(l =>
    {
       l.ItemClick.Handler = "myClickHandler(item,record,node,index,e)";
    }

设置服务器端属性:

section01.AttributesObject = new { nodeType = "Section" };

访问客户端自定义set属性:

function myClickHandler(item, record, node, index, e) {
    var nodeType = record.raw.nodeType;
    console.log(nodeType); //prints "Section"
}

最新更新