This article describes how ExtJS4 allocates different tree menus based on different roles after logon. If you need them, refer to the previous one. After setting cookies, extract them.
The Code is as follows:
Var userName = Ext. util. Cookies. get ('username ');
Var userAuthority = Ext. util. Cookies. get ('userauthority '); // 0, 1, 2
Now you can use
The Code is as follows:
// The tree menu is displayed based on different Permissions
Var treeUrl = '../store/REE' + userAuthority + '. json ';
Var treeStore = Ext. create ('ext. data. treestore ',{
Proxy :{
Type: 'ajax ',
Url: treeUrl
}
});
My tree menu is read from the local Device and Its names are ccTree0.json ~ CcTree2.json
You only need to use this treeStore when creating a tree menu. Some code is omitted below.
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, // reference it here
RootVisible: false,
RenderTo: Ext. getBody (),
Listeners :{
Itemclick: function (view, rec, el, index, e ){
// Alert (rec. id );
If (rec. raw. id = "01") {// specifies the first operation.
Paste the following json content for your reference.
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 that I have come up with to Implement User Classification... Please leave a message if you have a better method .. Thank you.