如何解决如何通过AJAX调用将菜单项动态添加到getStartConfig?
我正在Sencha Ext JS 7.0中创建一个桌面应用程序,登录后,将根据用户的角色和权限级别加载模块。
它必须替换左侧的“主页”和“设置”项:
我有一个正确返回模块的AJAX调用:
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 举报,一经查实,本站将立刻删除。