0

我试图通过输入输入 html 代码作为标签值的一部分在 dijit.Tree 中放置一个复选框。它显示正常,但我无法选中或取消选中它。好像点击事件没有冒泡/到达输入元素。

这是我创建树对象的方法。

myTree = new dijit.Tree({
    model: myModel,
    showRoot: false,            
    getLabel: function(item) {
        if (!item.root)
            return '<input type="checkbox" name="'+ item.name +'" id="'+ item.name +'" value="1" /> '+ item.name;
    }

}, "gridDiv");

我怎样才能解决这个问题 ?

4

2 回答 2

1

right now 2 choices come to my mind:

  1. Use the new dojo's dgrid if you can. With this new grid you can use the Editor module and pass "checkbox" as a parameter and it would render a checkbox in your column. Check it out here. Then you can download it here and when you do, check out the "test" folder where you will find an example of what you want in "dgrid/test/tree.html".
  2. in your current grid, edit your return statement for getLabel method and make it return a dojo style markup like <div data-dojo-type="dijit.form.CheckBox" ... ></div> and then after the tree's startup event do a dojo.parser.parse(tree.domNode). This will parse only your grid's DOM node and will convert any dojo style markup into actual dojo objects.

I personally recommend, if you can, the first choice.

Luck,

于 2012-08-05T01:54:48.650 回答
0

如果树中有复选框,我会选择 cbtree。 在这里检查

于 2013-04-16T06:00:03.913 回答