sapui5 - 将项目动态添加到 SelectDialog
问题描述
我需要SelectDialog
根据条件根据来自后端的 Odata 向控件添加更多项目。代码是,
if (!this._oDialog) {
this._oDialog = new sap.m.SelectDialog({});
this._oDialog.setModel(oParentModel);
this._oDialog.bindAggregation("items", {
path: "/et_getSidSet",
template: new sap.m.StandardListItem({
title: "{Sid}"
})
});
if (v === '1') {
var oItem1 = new sap.m.StandardListItem({
title: 'PC2',
type: 'Active'
});
this._oDialog.addItem(oItem1);
} else if (v === '2') {
var oItem1 = new sap.m.StandardListItem({
title: 'AC2',
type: 'Active'
});
this._oDialog.addItem(oItem1);
var oItem2 = new sap.m.StandardListItem({
title: 'IC2',
type: 'Active'
});
this._oDialog.addItem(oItem2);
}}
问题是,当我单击 helprequest 图标时,该项目不是第一次添加。但是,它是从第二次开始添加的。我需要第一次添加该项目。
提前致谢!
解决方案
使用SAPUI5
'sJSView
创建由按钮按下事件触发的对话框和径向图,您可以在此处查看完整的应用程序Plunkr 示例
openDialog: function() {
if (!this.draggableDialog) {
this.draggableDialog = new Dialog({
title: "Charts",
type: "Message",
contentWidth: "900px",
contentHeight: "700px",
resizable: true,
content: [
new RadialMicroChart({
percentage: 75,
total: 100,
size: "Responsive",
valueColor: "Critical"
})
],
beginButton: new Button({
text: "Close",
press: function() {
this.draggableDialog.close();
}.bind(this)
})
});
this.getView().addDependent(this.draggableDialog);
}
this.draggableDialog.open();
}
推荐阅读
- java - MongoDB 和 Spring MVC:PATCH 操作?
- kubernetes - Kubernetes NodePort 服务如何使用 Service.spec.externalTrafficPolicy=Local 路由流量?
- angular - 如何以角度将按钮角色添加到自定义元素以使其可由屏幕阅读器访问?
- python - Matplotlib 等高线图与曲线上的条件
- flutter - 颤振力为列表中的所有对象设置属性值
- google-kubernetes-engine - 有没有办法访问 Istio 在 GKE 中创建的 promsd 服务?
- json - 如何绕过 Nodebb 中先前声明的 json body-parser?
- reactjs - 如何使用基于条件的映射函数循环数组然后设置状态?
- hadoop - 在 Hadoop 中,如何验证我是否对 DFS 传输进行了数据加密?
- data-structures - 均衡四叉树单元的大小