ExtJS如何在提交时获取已检查的节点?

时间:2013-01-10 13:41:16

标签: javascript magento extjs prototypejs

我使用ExtJS 1.0.1(magento)

我想在表单提交上获取所有已检查的节点。我坚持到这里:

tree.html(初始化):

tree<?php echo $this->getId() ?> = new Ext.tree.TreePanel.Enhanced('<?php echo $_divId ?>', {
            animate:          false,
            loader:           categoryLoader,
            enableDD:         false,
            containerScroll:  true,
            rootVisible:      '<?php echo $this->getRoot()->getIsVisible() ?>',
            useAjax:          true,
            currentNodeId:    <?php echo (int) $this->getCategoryId() ?>,
            addNodeTo:        false
        });

关于提交功能:

function submit()
{

   console.log(tree'.$this->getId().');
   // got html code <div id="treeoptions_fieldset992cb0dd9a7da511e5596a229a5386d5_select_catalogb0f2cd4faa4f13b72f0df314bdc222ec" class="tree x-tree"><ul class="x-tree-root-ct x-tree-lines" id="ext-gen5859">...</ul></div>

   var checked_nodes = tree'.$this->getId().'.getChecked();
   // got an error Uncaught TypeError: Object #<HTMLDivElement> has no method 'getChecked'
}

Magento在管理面板中使用prototypeJS。 问题是如何解决check_nodes运行getChecked()?

2 个答案:

答案 0 :(得分:1)

基于一些关于EXTJS树功能的谷歌搜索,试试这个

var checked_nodes = tree'.$this->getId().'.select(".x-grid-row-selected");
console.log(checked_nodes);

.select()方法查找与所选CSS选择器匹配的所有子节点

答案 1 :(得分:0)

上班!

我在treegetId()之后创建了对象?&gt; INIT:

function av_OkButton()
    {
        var tree = null;

        this.onPress = function()
        {
            var ids = this.tree.getChecked();
        }

        this.getTree = function()
        {
            return this.tree;
        }

        this.setTree = function(treeObj)
        {
            this.tree = treeObj;

            return this;
        }
    }

okButton = new av_OkButton;
okButton.setTree(tree<?php echo $this->getId() ?>);

然后创建提交按钮:

无法理解我之间的区别和现在的区别,但它对我有用