如何访问(Grails插件)<richui:treeview>标记中的node.depth属性?

时间:2017-10-10 19:31:00

标签: grails plugins treeview

该插件表示您可以使用标记中的“node.depth”来确定单击的标签级别(国家/地区或省级)。我似乎无法从RichUI:treeview标记访问node.depth。当1或2的值被硬编码到onLabelClick时,我的代码工作正常。但是当我指定node.depth作为参数时,没有任何东西被传递给javascript。我如何访问node.depth?我的提醒说“级别未定义”

<richui:treeView id="tree" xml="${data}" 
onLabelClick="treeClickHandler(node.depth, id)" showRoot="false"/>


function treeClickHandler(level, id){
    alert("level is " + level + " and id is " + id);
    if (level == 1){
        postForCountryIdeas(id);
    }
    else{
        postForProvControls(id);
    }
}

def index() {
def countryList = Country.list()
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
def writer2 = new StringWriter()
def xml2 = new MarkupBuilder(writer2)
xml2.mkp.xmlDeclaration(version: "1.0", encoding: "utf-8")
xml2.countrys {
    countryList.each{item->
        xml2.country(name:"${item.name}", id: item.id){
            item.provinces.each{ prov-> 
            province(name:"${prov.name}", id: prov.id)
            }
        }
    }
}
[data: writer2.toString()]
}

1 个答案:

答案 0 :(得分:0)

解决方案是根据文档使用node.node.depth而不是node.depth。