ExtJS4 allocates different tree menus based on different roles after logon _ extjs

Source: Internet
Author: User
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.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.