摘要:dojo-dijit tree選單-直接在js裡面使用datasource:testStore-不引用url json
<script type="text/javascript" src="/dojo/dojo/dojo.js" djConfig="isDebug:true,parseOnLoad: true,bindEncoding:'UTF-8'"></script> <!--<link href="/dojo/dijit/themes/nihilo/nihilo.css" rel="stylesheet" type="text/css" /> -->
<link href="/dojo/dojo/resources/dojo.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="/dojo/dijit/themes/tundra/tundra.css" />
<body class="tundra">
<script language="JavaScript" type="text/javascript">
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dijit.Tree");
dojo.require("dojo.parser");
dojo.require("dijit.MenuBar");
dojo.require("dijit.MenuItem");
dojo.require("dijit.PopupMenuItem");
var testStore = {
identifier: 'name',
label: 'name',
items: [
<已計算完值><已計算完值>,{ name:'離開', type:'continent',locatoin:'./',Tag:'Top',RunUrl:'Y'}
]
};
</script>
<div dojoType="dojo.data.ItemFileReadStore" jsId="continentStore"
data="testStore"></div>
<div dojoType="dijit.Tree" id="tree1" store="continentStore" query="{type:'continent'}"
labelAttr="name" label="">
<script type="dojo/method" event="onClick" args="item">
if(item){
//alert("Type:" + continentStore.getLabel(item,"type"));
if (continentStore.getValue(item, "type")=="country" || continentStore.getValue(item, "RunUrl")=="Y" ){
var tagtmp=window.location.target=continentStore.getValue(item, "Tag");
if (tagtmp=="Top"){top.window.location =continentStore.getValue(item, "locatoin");}
else if(tagtmp=="Body"){window.parent.Body.location.href =continentStore.getValue(item, "locatoin");}
}
//top.window.location=continentStore.getValue(item, "locatoin");}
// alert("Execute of node " + continentStore.getLabel(item)
// +", locatoin=" + continentStore.getValue(item, "locatoin"));
}else{
//alert("Execute on root node");
}
</script>
</div>
</body>