ExtJS4 assigns different tree menus to different roles after login
- 2020-03-30 02:46:02
- OfStack
Continue with my previous post, set the cookies and take them out
And then you can use it
My tree menu is read locally with the names cctree0.json ~ cctreee2.json
Just use this treeStore to create the tree menu, which is omitted below
Paste the json content below for your reference
The above is just a way I came up with to achieve user classification... Leave a message if there's a better way. thank you
var userName = Ext.util.Cookies.get('userName');
var userAuthority = Ext.util.Cookies.get('userAuthority');//0,1,2
And then you can use it
//The 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 menu is read locally with the names cctree0.json ~ cctreee2.json
Just use this treeStore to create the tree menu, which is omitted below
//The 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"){//I'm going to do the same thing with the first one
Paste the json content below for your reference
[
{id:"01",text:" The first one ",expanded:false,leaf:true,"children":[
],url:'login.html'},
{id:"02",text:" The second ",expanded:true,"children":[
{id:"021",text:" The third ",leaf:true},
{id:"022",text:" The fourth ",leaf:true}
]},
{id:"03",text:" The fifth ",expanded:true,"children":[
{id:"031",text:" The sixth ",leaf:true},
{id:"032",text:" The seventh ",leaf:true}
]}
]
The above is just a way I came up with to achieve user classification... Leave a message if there's a better way. thank you