[Javascript]
<script id="treeTemplate" type="text/x-jsrender">
{{if hasChild}}
<div class={{>cls}}>{{>name}}</div>
{{else}}
<div class="cont-list">
<button class="con-img">{{>imgId}}"</button>
<div class="cont-details">
<b>{{>name}}</b><br />
<span>{{>city}}</span>
<br />
<span>{{>phone}}</span>
</div>
<div class="treeFooter"></div>
</div>
{{/if}}
</script>
$("#treeview").ejTreeView({
fields: {
dataSource: treeData,
id: "id", parentId: "pid", text: "name", hasChild: "hasChild"
},
template: "#treeTemplate",
nodeSelect: function (args) {
// Hide the all buttons inside the tree view
this.element.find('li .con-img').hide();
// Show the corresponding button for the selected item.
$(args.currentElement.closest('li')).find('button').show();
},
ready: function (args) {
this.element.find('li .con-img').hide();
}
}); |