Bonjour ,
J 'ai un projet qui utilise Dojo mais je suis novice sur ce framework.
Je vous explique mon problème , je récupère l 'arborescence de mon système de fichier et j 'essaie de l 'afficher avec un DijitTree.Donc tout fonctionne bien sauf que quand j 'ouvre l ' arborescence il n 'ouvre que le dossier racine , si je clique sur un dossier à l 'intérieur de l 'arbre il n 'arrive pas à l 'ouvrir .
J 'utilise Json_encode pour encoder ma chaine sous format Json .
Ci dessous un exemple de mon Json encodé:
var data = {"total":3,"items":[{"name":"nouveau fichier","parentDir":".","path":".\/nouveau fichier","directory":false,"size":28,"modified":1262011640},{"name":"Plug-in Tutorial ","parentDir":".","path":".\/Plug-in Tutorial ","directory":true,"size":4096,"modified":1260395078,"children":["Read Me.txt","security.zip","Model Statistics","security-instance.zip","edu.cmu.sei.osate.examples.security-instance","edu.cmu.sei.osate.examples.security","Plug-in Tutorial 2006-09-11.pdf","FlowLatencyAnalysisSwitch2.java"]},{"name":"ralin","parentDir":".","path":".\/ralin","directory":false,"size":10364,"modified":1262089596}]}
Ci dessous le code que j 'utilise pour afficher l 'arbre
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
<body class="tundra ">
<ul dojoType="dijit.Menu" id="tree_menu" style="display: none;">
<li dojoType="dijit.MenuItem" onClick="alert('Hello world');">
Upload
</li>
<li dojoType="dijit.MenuItem">
Download
</script>
</li>
</ul>
<div dojoType="dojo.data.ItemFileReadStore" data="liste" jsId="DojoFile">
</div>
<div dojoType="dijit.tree.ForestStoreModel" jsId="fileModele"
store="DojoFile" query="{}" rootId="testArbre"
rootLabel="ListeFich" childrenAttrs="children" labelAttr="name">
</div>
<div id="arbre" dojoType="dijit.Tree" model="fileModele" openOnClick="true" showRoot="true" >
<script type="dojo/connect">
var menu = dijit.byId("tree_menu");
// when we right-click anywhere on the tree, make sure we open the menu
menu.bindDomNode(this.domNode);
dojo.connect(menu, "_openMyself", this, function(e) {
// get a hold of, and log out, the tree node that was the source of this open event
var tn = dijit.getEnclosingWidget(e.target);
console.debug(tn);
// now inspect the data store item that backs the tree node:
console.debug(tn.item);
// contrived condition: if this tree node doesn't have any children, disable all of the menu items
menu.getChildren().forEach(function(i) {
i.attr('disabled', !tn.item.children);
});
});
</script>
</div> |
C 'est sur le children qui ne marche pas car il n 'arrive pas afficher ce qu 'il y a dans children.
Pourrez -vous m 'aider s'il vous plaît car j 'ai essayé divers méthodes mais ça ne marche pas.
Merci
Partager