2017-10-10 54 views
0

該插件說,您可以使用標籤中的'node.depth'來確定已經點擊了哪個標籤級別(國家或省)。我似乎無法從RichUI:treeview標記訪問node.depth。當1或2的值硬編碼到onLabelClick中時,我的代碼工作正常。但是當我指定node.depth作爲參數時,沒有任何東西會傳遞給javascript。我如何訪問node.depth?我警告說,「級別未定義」如何訪問(Grails插件)<RichUI:treeview>標記中的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()] 
} 

回答

0

的解決方案是node.node.depth改用node.depth的按的文檔。