环境 Extjs4.2
做tree一次性从后台加载数据的时候,发现返回了数据结构,包含了children子节点结合,前端还是会继续查询每个节点的子节点,最后发现是我这边TreeStore定义有问题,
这里的root写了是res。但是后台传过来的时候,子节点写的是children。这里将后台返回数据的子节点的名字改成res。就好了
原先定义的是private List children;
后修改为 private List res
。extjs原文如下。
For the tree to read nested data, the Ext.data.reader.Reader must be configured with a root property, so the reader can find nested data for each node (if a root is not specified, it will default to ‘children’). This will tell the tree to look for any nested tree nodes by the same keyword, i.e., ‘children’. If a root is specified in the config make sure that any nested nodes with children have the same name. Note that setting defaultRootProperty accomplishes the same thing.