问题描述
我正在Sencha Ext JS 7.0中创建一个桌面应用程序,登录后,将根据用户的角色和权限级别加载模块。
它必须替换左侧的“主页”和“设置”项:
userModuleMenu: function()
{
Ext.Ajax.request(
{
url: 'ajax_url',method: 'POST',cors: true,useDefaultXhrHeader : false,params:
{
module: 'module_name',action: 'get_modules',user_id: userid
},success: function(response,xhr,status)
{
// If call was successful
var result = JSON.parse(response.responseText);
var resultType;
if(result.success)
{
// The menu
var moduleMenu = result.result;
return moduleMenu;
}
else
{
resultType = 'Failed';
Ext.Msg.alert(resultType,result.result,function(btn,text)
{
if(btn == 'ok')
{
}
});
}
},failure: function(response,status)
{
Ext.Msg.alert('Failed','Failed');
},scope: this
});
},
哪个返回这样的数组:
0: {...}
handler: "Accountinformation"
iconCls: null
scope: "me"
text: "Account information"
1: {...}
handler: "AccountDetails"
iconCls: "mol_accountdetails"
scope: "me"
text: "Account Details"
2: {...}
handler: "ContactYourAdministrator"
iconCls: "mol_Feedback"
scope: "me"
text: "Contact Your Administrator"
3: {...}
handler: "ChangePassword"
iconCls: "mol_password"
scope: "me"
text: "Change Password"
4: {...}
handler: "Administration"
iconCls: null
scope: "me"
text: "Administration"
5: {...}
handler: "AccountConfiguration"
iconCls: "bo_account_management"
scope: "me"
text: "Account Configuration"
这就是我重写getStartConfig()的方式:
getStartConfig: function()
{
var me = this,ret =
{
app: me,menu: [
{
text: 'Home',iconCls: 'x-fa fa-home',handler: me.onHome,scope: me
},{
text: 'Settings',iconCls: 'x-fa fa-cogs',handler: me.onSettings,scope: me
}],};
return Ext.apply(ret,{
title: 'Menu',iconCls: 'x-fa fa-user',height: 400,toolConfig: {
width: 100,items: [
{
text: 'Settings',scope: me
},'-',{
text: 'logout',iconCls: 'x-fa fa-sign-out-alt',handler: me.userStoreRemove,scope: me
}
]
}
});
},
如何使用AJAX调用作为存储来填充getStartConfig()覆盖中的菜单项?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)