Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Checkbox 如何在extjs4中将复选框添加到树节点_Checkbox_Extjs4_Treeview - Fatal编程技术网

Checkbox 如何在extjs4中将复选框添加到树节点

Checkbox 如何在extjs4中将复选框添加到树节点,checkbox,extjs4,treeview,Checkbox,Extjs4,Treeview,我在extjs4中工作。我有树面板的视图- Ext.define('Balaee.view.qb.qbquestion.tree1', { extend: 'Ext.tree.Panel', title: 'Simple Tree', width: 200, height: 150, alias : 'widget.tree1', //store: 'qb.qbquestioncomplexityStore', rootVisible: t

我在extjs4中工作。我有树面板的视图-

Ext.define('Balaee.view.qb.qbquestion.tree1', {

    extend: 'Ext.tree.Panel',
    title: 'Simple Tree',
    width: 200,
    height: 150,
    alias : 'widget.tree1',
   //store: 'qb.qbquestioncomplexityStore',
    rootVisible: true,
    renderTo: Ext.getBody()
});
在控制器中,我创建了静态存储。并将其绑定到此视图。代码如下-

 var store = Ext.create('Ext.data.TreeStore', {
            root: {
                expanded: true,
                children: [
                    { text: "detention", leaf: true },
                    { text: "homework", expanded: true, children: [
                        { text: "book report", leaf: true },
                        { text: "algebra", leaf: true}
                    ] },
                    { text: "buy lottery tickets", leaf: true }
                ]
            }
        });

     var bchart=Ext.create('Balaee.view.qb.qbquestion.tree1',{
         store:store

     });
     var comp=Ext.getCmp('QuestionView');
     comp.removeAll();
     comp.add(bchart);

它工作正常。它正确显示树面板视图。但是如何将复选框添加到此树节点

您需要将
checked
属性添加到树节点数据
true
false
。此属性的存在将告诉ExtJs为节点添加复选框

树的
子节点的定义示例:

children: [
                    { text: "detention", leaf: true, checked: true },
                    { text: "homework", expanded: true, children: [
                        { text: "book report", leaf: true },
                        { text: "algebra", leaf: true, checked: false}
                    ] },
                    { text: "buy lottery tickets", leaf: true }
          ]