Hi All
I have a treeview.js and I wrote json code for items n subitems in .aspx page javascript.
I need to write code for multiselecting treeview nodes after that if i click on a button the selected nodes should be copied or moved to another component(probably another div).
below r the treeview.js and javascript code i used
I also need a treeview.js which is suitable for this task to work.Please provide a link for latest version of treeview.js
treeview.js
treeview = function(tData, container)
{
this.build = function(nodeInfo)
{
var nodeID = nodeInfo['title'].replace(/\s/g, "_");
var node = $('<div id="'+nodeID+'-Node">'+nodeInfo['title']+'</div>')
.css({'margin-top': 5});
$('<div></div>')
.prependTo(node);
var contents = $('<div></div>');
for(item in nodeInfo['items'])
{
if(typeof nodeInfo['items'][item] == 'string' ||
typeof nodeInfo['items'][item] == 'number')
{
$('<div></div>')
.html('<span>'+item+'</span><div>'+nodeInfo['items'][item]+'</div>')
.appendTo(contents);
}
if(typeof nodeInfo['items'][item] == 'object')
{
sNode = this.build(nodeInfo['items'][item]);
contents.append(sNode);
}
}
node.append(contents);
node.children('.expandNode').click(function() {
var contents = $(this).parent().children(".NodeContents");
contents.toggle();
if(contents.css('display') != "none")
{
$(this).attr("class", "expandNode collapse");
}
else
{
$(this).attr("class", "expandNode expand");
}
});
return node;
}
this.tree = this.build(tData);
var treeCon = container;
treeCon.append(this.tree);
}
javascript code
<script type="text/javascript">
$(document).ready(function() {
var data = {
'title': "Type",
'items': {
"Item 4": {
'title': "Color",
'items': {
"Color 1": "Red",
"Color 2": "Blue",
"Color 3": "White"
}
},
"Item 5": {
'title': "Size",
'items': {
"Size 1": "10",
"Size 2": "12",
"Size 3": "13"
}
}
}
};
tView = new treeview(data, $('#Div1'));
});
</script>
Thanks n Regards
Shyam