前臺(tái)頁面:
<pre name="code" class="html"><td style="height: 35px" colspan="7"> <input id="fm_AEType" class="easyui-combotree" style="width: 240px" /> <label id="fm_AETypePath" /> </td></pre>
JavaScript頁面(包括數(shù)據(jù)初始化):
initAEType: function () { $.ajax({ url: AEActionUrl + '?action=listaetype&ParentType=', dataType: 'json', success: function (jsonstr) { $('#fm_AEType').combotree({ data: jsonstr, editable: false, //lines: true, valueField: 'AE_TYPE_ID', textField: 'AE_TYPE_NAME', onLoadSuccess: function () { $('#fm_AEType').combotree('tree').tree("collapseAll"); }, onSelect: function (item) { var parent = item; var tree = $('#fm_AEType').combotree('tree'); var path = new Array(); do { path.unshift(parent.text); var parent = tree.tree('getParent', parent.target); } while (parent); var pathStr = ''; for (var i = 0; i < path.length; i++) { pathStr += path[i]; if (i < path.length - 1) { pathStr += ' - '; } } $('#fm_AETypePath').text(pathStr); } }); } }); }
如上,關(guān)鍵代碼在onSelect事件中。
以上就是小編為大家?guī)淼膃asyui中combotree循環(huán)獲取父節(jié)點(diǎn)至根節(jié)點(diǎn)并輸出路徑實(shí)現(xiàn)方法全部內(nèi)容了,希望大家多多支持武林網(wǎng)~
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注