0

我使用 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。问题是如何处理checked_nodes 来运行getChecked()?

4

2 回答 2

1

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

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

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

于 2013-01-10T21:13:05.137 回答
0

得到作品!

我在 treegetId() ?> 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() ?>);

然后创建提交按钮:

无法理解我所做的与我现在拥有的有什么区别,但它对我有用

于 2013-01-11T05:34:50.800 回答