我们使用的是extjs 3.2.1 JavaScript框架。在其中一个网格面板上有一个动作菜单。根据从数据库中检索的值,我需要显示或隐藏菜单。为此,我可以使用菜单的隐藏属性。ExtJs处理异步调用
问题是我用来异步检索数据库运行值的函数,并且需要时间来检索该值,并且在返回时菜单已经被初始化。这里有两种方法。
employeeProfile: function(profileType) {
CR.Controllers.Employee.GetProfile(function(result) {
if (CR.CRError.ParseResult(result)) {
switch (profileType) {
case "IsStandardAllowed":
return result.IsStandardAllowed === 1 ? true : false;
case "IsUploadAllowed":
return result.IsUploadAllowed === 1 ? true : false;
case "IsCopyAllowed":
return result.IsCopyAllowed === 1 ? true : false;
default:
return true;
}
}
return true;
}, this);
},
getMenuActions:
function() {
return [
// add button
new CR.EmployeePanelAction({
text: this.lang_newFromStandard,
tooltip: this.lang_tipNewFromStandard,
handler: this.onNewFromTemplate,
hidden: this.EmployeeProfile("IsStandardAllowed")
scope: this
}),
new CR.EmployeePanelAction({
text: this.lang_newFromUpload,
tooltip: this.lang_tipNewFromUpload,
handler: this.onNewFromUpload,
hidden: this.employeeProfile("IsUploadAllowed"),
scope: this
}),
new CR.EmployeePanelAction({
text: this.lang_newFromCopy,
tooltip: this.lang_tipNewFromCopy,
handler: this.onNewFromCopy,
hidden: this.employeeProfile("IsCopyAllowed"),
scope: this
})
];
},
它的作品,如果我设置隐藏真或假。问题是我必须从数据库中获取价值,无论我是否需要隐藏。数据库调用运行异步并在菜单初始化后返回 –
@MuthuAnnamalai使用'hide()'函数,可以隐藏或显示已初始化的组件,那么问题出在哪里? – Alexander
初始化后,我试图从数据库访问this.getMenuActions [0] .hidden = value,但没有为我工作。我真的不知道我在哪里犯错。 –