ExtJS4利根據(jù)登錄后不同的角色分配不同的樹形菜單
更新時間:2014年05月02日 11:56:33 作者:
這篇文章主要介紹了ExtJS4利根據(jù)登錄后不同的角色分配不同的樹形菜單,需要的朋友可以參考下
繼續(xù)我的上一篇,設(shè)置好cookie后,將他們?nèi)〕鰜?
var userName = Ext.util.Cookies.get('userName');
var userAuthority = Ext.util.Cookies.get('userAuthority');//0,1,2
接下來就可以用了
//樹形菜單根據(jù)不同權(quán)限顯示
var treeUrl='../store/ccTree'+userAuthority+'.json';
var treeStore = Ext.create('Ext.data.TreeStore', {
proxy:{
type:'ajax',
url:treeUrl
}
});
我的樹形菜單從本地讀取,名字分別為ccTree0.json~ccTree2.json
建立樹形菜單的時候只要用這個treeStore就行了,下面省略了部分代碼
//樹形菜單
var menuTree=Ext.create('Ext.tree.Panel', {
// title: 'Simple Tree',
width: 200,
height: 650,
useArrows:true,
store: treeStore,//在這里引用
rootVisible: false,
renderTo: Ext.getBody(),
listeners:{
itemclick: function(view,rec,el,index,e) {
// alert(rec.id);
if(rec.raw.id=="01"){//對點了第一個的操作,其他類似
下面貼下json的內(nèi)容以供參考
[
{id:"01",text:"第一個",expanded:false,leaf:true,"children":[
],url:'login.html'},
{id:"02",text:"第二個",expanded:true,"children":[
{id:"021",text:"第三個",leaf:true},
{id:"022",text:"第四個",leaf:true}
]},
{id:"03",text:"第五個",expanded:true,"children":[
{id:"031",text:"第六個",leaf:true},
{id:"032",text:"第七個",leaf:true}
]}
]
以上只是我自己想出來的一種實現(xiàn)用戶分類的方法。。。有更好的方法請留言。。謝謝
復(fù)制代碼 代碼如下:
var userName = Ext.util.Cookies.get('userName');
var userAuthority = Ext.util.Cookies.get('userAuthority');//0,1,2
接下來就可以用了
復(fù)制代碼 代碼如下:
//樹形菜單根據(jù)不同權(quán)限顯示
var treeUrl='../store/ccTree'+userAuthority+'.json';
var treeStore = Ext.create('Ext.data.TreeStore', {
proxy:{
type:'ajax',
url:treeUrl
}
});
我的樹形菜單從本地讀取,名字分別為ccTree0.json~ccTree2.json
建立樹形菜單的時候只要用這個treeStore就行了,下面省略了部分代碼
復(fù)制代碼 代碼如下:
//樹形菜單
var menuTree=Ext.create('Ext.tree.Panel', {
// title: 'Simple Tree',
width: 200,
height: 650,
useArrows:true,
store: treeStore,//在這里引用
rootVisible: false,
renderTo: Ext.getBody(),
listeners:{
itemclick: function(view,rec,el,index,e) {
// alert(rec.id);
if(rec.raw.id=="01"){//對點了第一個的操作,其他類似
下面貼下json的內(nèi)容以供參考
復(fù)制代碼 代碼如下:
[
{id:"01",text:"第一個",expanded:false,leaf:true,"children":[
],url:'login.html'},
{id:"02",text:"第二個",expanded:true,"children":[
{id:"021",text:"第三個",leaf:true},
{id:"022",text:"第四個",leaf:true}
]},
{id:"03",text:"第五個",expanded:true,"children":[
{id:"031",text:"第六個",leaf:true},
{id:"032",text:"第七個",leaf:true}
]}
]
以上只是我自己想出來的一種實現(xiàn)用戶分類的方法。。。有更好的方法請留言。。謝謝
相關(guān)文章
Ext JS 4實現(xiàn)帶week(星期)的日期選擇控件(實戰(zhàn)二)
Javascript 有提供Date 對象用于處理時間。但是Date 并沒有提供獲取星期的方法,jquery 的擴展組件 等有直接提供這樣的一些現(xiàn)成包,感興趣的朋友可以了解下2013-08-08Ext中下拉列表ComboBox組件store數(shù)據(jù)格式用法介紹
本文為大家詳細(xì)介紹下Ext中下拉列表ComboBox組件store數(shù)據(jù)格式的基本用法,感興趣的朋友可以參考下哈,希望對大家有所幫助2013-07-07Extjs3.0 checkboxGroup 動態(tài)添加item實現(xiàn)思路
Extjs3.0中的CheckboxGroup默認(rèn)不能動態(tài)添加item,如需要數(shù)據(jù)動態(tài)創(chuàng)建,試著創(chuàng)建整個CheckboxGroup,而不是動態(tài)添加item,具體實現(xiàn)如下,感興趣的朋友可以了解下2013-08-08ExtJS Store的數(shù)據(jù)訪問與更新問題
ExtJS Store的數(shù)據(jù)訪問與更新問題,需要的朋友可以參考下。2010-04-04ExtJS4如何自動生成控制grid的列顯示、隱藏的checkbox
需要做一個控制grid列顯示的checkboxgroup,雖然EXTJS4中的gridpanel自帶列表可以來控制列的顯示隱藏,需要的朋友可以參考下2014-05-05解決ExtJS在chrome或火狐中正常顯示在ie中不顯示的瀏覽器兼容問題
由于開發(fā)過程中大多用chrome來調(diào)試,很少在ie中調(diào)試(現(xiàn)在兩者都要兼顧),導(dǎo)致最后在ie中頁面不能正常加載,當(dāng)時那個囧啊,看到ie報的錯,我都想哭,連出錯的堆棧信息都沒有(這一點,ie做的真不好),無從下手啊2013-01-01