Continuing with my previous article, after setting the cookies, take them out
var userName = Ext.util.Cookies.get('userName');
var userAuthority = Ext.util.Cookies.get('userAuthority');//0,1,2
You can use it next
/ /Tree menu is displayed according to different permissions
var treeUrl='../store/ccTree' userAuthority '.json';
var treeStore = Ext.create('Ext.data.TreeStore ', {
proxy:{
type:'ajax',
url:treeUrl
}
});
My tree shape The menu is read from the local, and the names are ccTree0.json~ccTree2.json
When creating a tree menu, just use this treeStore. Part of the code is omitted below
//Tree menu
var menuTree=Ext.create('Ext.tree .Panel', {
// title: 'Simple Tree',
width: 200,
height: 650,
useArrows:true,
store: treeStore,//Quote here
rootVisible: false,
renderTo: Ext.getBody(),
listeners:{
itemclick: function(view,rec,el,index,e) {
// alert(rec .id);
if(rec.raw.id=="01"){// Click the first operation, others are similar
Post the json content below to For reference
[
{id: "01" ,text:"first",expanded:false,leaf:true,"children":[
],url:'login.html'},
{id:"02",text :"second",expanded:true,"children":[
{id:"021",text:"third",leaf:true},
{id:"022",text :"Fourth",leaf:true}
]},
{id:"03",text:"Fifth",expanded:true,"children":[
{id:"031",text:"Sixth",leaf:true},
{id:"032",text:"Seventh",leaf:true}
]}
]
The above is just a method I came up with to implement user classification. . . If you have a better way, please leave a message. . Thanks