Home > Web Front-end > JS Tutorial > ExtJS4 distributes different tree menus according to different roles after login_extjs

ExtJS4 distributes different tree menus according to different roles after login_extjs

WBOY
Release: 2016-05-16 16:50:20
Original
1413 people have browsed it

Continuing with my previous article, after setting the cookies, take them out

Copy the code The code is as follows:

var userName = Ext.util.Cookies.get('userName');
var userAuthority = Ext.util.Cookies.get('userAuthority');//0,1,2

You can use it next
Copy the code The code is as follows:

/ /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
Copy code The code is as follows:

//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
Copy code The code is as follows:

[
{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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template