Saturday, 15 June 2013

javascript - dynatree js showing tree expanded initially -



javascript - dynatree js showing tree expanded initially -

i have created js tree dynatree.js. have long hierarchy. tree showing expanded on load. want tree should expand 1 level. below code

<apex:component controller="treeviewcontroller"> <apex:attribute name="roleoruserid" required="true" type="string" assignto="{!roleoruserid}" description="enter role or user id build hierarchy. pass null if passing json info parameter" /> <apex:attribute name="selectable" type="boolean" assignto="{!selectable}" description="do want nodes selectable?" /> <apex:attribute name="value" type="string" description="ids of selected nodes in csv format" /> <apex:attribute name="jsondata" type="string" assignto="{!jsondata}" description="json input tree component" /> <apex:inputhidden id="selectedkeys" value="{!value}" /> <!--<apex:includescript value="{!urlfor($resource.dynatree, 'jquery/jquery.js' )}" /> --> <apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"/> <apex:includescript value="{!urlfor($resource.dynatree, 'jquery/jquery-ui.custom.js' )}" /> <apex:includescript value="{!urlfor($resource.dynatree, 'jquery/jquery.cookie.js' )}" /> <apex:includescript value="{!urlfor($resource.dynatree, 'src/jquery.dynatree.js' )}" /> <!--<apex:includescript value="{!$resource.dynatreejs}" /> --> <apex:stylesheet value="{!urlfor($resource.dynatree, 'src/skin/ui.dynatree.css')}" /> <!-- add together code initialize tree when document loaded: --> <script type="text/javascript"> $.noconflict(); $(document).ready(function() { $(function(){ // attach dynatree widget existing <div id="tree"> element // , pass tree options argument dynatree() function: $("#tree").dynatree({ onactivate: function(node) { // dynatreenode object passed activation handler // note: event, if persistence on, , page reloaded. //alert("you activated " + node.data.key); }, persist: false, checkbox: true, generateids: false, classnames: { checkbox: "dynatree-checkbox", expanded: "dynatree-expanded" }, selectmode: 3, children: {!jsonstring}, onselect: function(select, node) { // list of selected nodes, , convert key array: var selkeys = $.map(node.tree.getselectednodes(), function(node){ homecoming node.data.key; }); jquery(document.getelementbyid("{!$component.selectedkeys}")).val(selkeys.join(", ")); // list of selected top nodes var selrootnodes = node.tree.getselectednodes(true); // ... , convert key array: var selrootkeys = $.map(selrootnodes, function(node){ homecoming node.data.key; }); }, }); }); }); </script> <!-- add together <div> element tree should appear: --> <div id="tree"> </div> </apex:component> the output

a tree sub nodes open till lastly level. want first lavel open. howw tat. there setting or else? please help

everything in dynatree docs , examples. check minexpandlevel http://wwwendt.de/tech/dynatree/doc/sample-minexpand.html

javascript tree salesforce visualforce

No comments:

Post a Comment