如何在我的对话列表中访问 JSON 模型中的值?

How do I access the values in the JSON model in my Dialogue list?

我已从 UI5 中的 ajax 调用中检索到 JSON 模型,但我无法访问其成员。我见过人们做类似事情的例子,但它对我不起作用。这是我的代码:

onSumbmitFlowGAkQ: function () {
            var oParameters = {
                "value": this.getView().byId("flowInputGAK").getValue()
            };

            $.ajax({
                url: "private url",
                type: 'POST',
                data: JSON.stringify(oParameters),
                contentType: 'application/json',
                success: function (data) {
                    this.getView().setModel(new JSONModel(data), "guidedAssistanceGAK");
                    this.setUpDialog();
                }.bind(this),
                error: function (e) {
                    MessageToast.show(e.status);
                }
            });

setUpDialog: function () {
            var lst = new List({
                items: {
                    path: "guidedAssistanceGAK>/flow",
                    template: new StandardListItem({
                        title: "{guidedAssistanceGAK>value}",
                        counter: "{guidedAssistanceGAK>ID}"
                    })
                }
            });
            var dialog = new Dialog({
                title: "choose one",
                content: lst,
                beginButton: new Button({
                    text: "OK",
                    press: function () {
                        dialog.close();
                    }
                }),
                afterClose: function () {
                    dialog.destroy();
                }
            });
            dialog.open();
            //this.oEditor.oRichTextEditor.setValue(this.getView().getModel("guidedAssistanceGAK").getProperty("/flow"));
        },

我正在使用语法 "guidedAssistanceGAK>/flow" 来访问数据,但它不起作用。我认为这是一个绑定错误。我想知道这样做的正确方法是什么。

新对话框看起来不是视图的一部分,而视图是您的模型所在的位置。您可以执行 this.getView().addDependent(dialog),也可以使用 dialog.setModel 将模型附加到对话框。