Bonjour,
Je rencontre des problèmes pour utiliser un arbre.
Voici mon code :
	
	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 45 46 47 48 49 50 51 52 53 54 55 56 57
   |  
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr">
 
    <head>
        <style type="text/css">
            body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
        </style>
        <script type="text/javascript">
		var djConfig = {
					isDebug:true,
					parseOnLoad:true
		};
		</script>
		<script type="text/javascript" src="../js/dojo-release-1.5.0/dojo/dojo.js"></script>
        <script type="text/javascript">
            dojo.require("dojo.data.ItemFileReadStore");
            dojo.require("dijit.Tree");
        </script>
        <link rel="stylesheet" type="text/css" href="../js/dojo-release-1.5.0/dijit/themes/claro/claro.css"/>
    </head>
 
    <body class=" claro ">
        <div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore" url="../data/countries.json">
        </div>
        <div dojoType="dijit.tree.ForestStoreModel" jsId="continentModel" store="continentStore"
        query="{type:'continent'}" rootId="continentRoot" rootLabel="Continents"
        childrenAttrs="children">
        </div>
        <div dojoType="dijit.Tree" id="mytree" model="continentModel" autoExpand="false" openOnClick="true" openOnDblClick="false">
            <script type="dojo/method" event="onClick" args="item">
                alert("Execute of node " + continentStore.getLabel(item) + ", population=" + continentStore.getValue(item, "population"));
			</script>
			<script type="dojo/method" event="getLabelStyle" args="item,opened">
				/*if(item && continentStore.getValue(item,"type") == "continent"){
					return {color: "red"};
				}else{
					return {color: "green"};
				}*/
			</script>
			<script type="dojo/method" event="getTooltip" args="item">
				return item && ("Tooltip de " + this.model.getLabel(item));
			</script>
        </div>
        <!-- NOTE: the following script tag is not intended for usage in real
        world!! it is part of the CodeGlass and you should just remove it when
        you use the code -->
        <script type="text/javascript">
            dojo.addOnLoad(function() {
                if (document.pub) {
                    document.pub();
                }
            });
        </script>
    </body>
 
</html> | 
 C'est cette partie de mon code qui pose problème :
	
	continentStore.getValue(item,"type") == "continent"
 En fait je passe par l'objet dijit.tree.ForestStoreModel comme conseillé dans la doc (http://docs.dojocampus.org/dijit/Tree). Ci je ne passe pas par cet objet tout fonctionne...
Ce site : http://archive.dojotoolkit.org/night...test_Tree.html le fait sans passer par l'objet dijit.tree.ForestStoreModel.
Je voudrais savoir comment faire en utilisant l'objet model.
Merci pour votre aide.
						
					
Partager