How to Count Children Nodes on Javascript Fancytree?

I created a Category tree using Fancytree with Drag & Drop Functionality like

How to Count Children Nodes on Javascript Fancytree?

Now, I want to set limit for child node. if parent node already have 3 child node then his not able to create new child not for example

Category

parent category

  • child category Allowed
    • Child Category Allowed
      • Child Category Not Allowed to Move

like this so i create javascript for this.

dragDrop: function(node, data) { if( node.getLevel() >= 3 ){     return false; } console.log( node ); console.log( data ); var parentNodeKey = node.key; var sourceNode = $(data.helper).data("ftSourceNode"); if( !data.otherNode ){     var title = $(data.draggable.element).text() + " (" + (count)++ + ")";     node.addNode({title: title}, data.hitMode);     return; } data.otherNode.moveTo(node, data.hitMode); 

}

This is working fine when i move any single category. but this is not working when i move "Moved Node" category because this category already have a 2 child node and that child node already have 2 child nodes like

How to Count Children Nodes on Javascript Fancytree?

I move the "Moved Node" and this is Working how can i count that child nodes or stop to moved that nodes. i want to set limit for creating 3 child nodes. How can i do this. and how can i count the all child nodes of moveing category.

Thanks

Replay

Child nodes can be counted using node.countChildren, but from your description I guess you want to count the maximum level of child nodes?

There is no builtin method for that, but you can implement it using node.visit().

Category: javascript Time: 2016-01-16 Views: 8

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.105 (s). 12 q(s)