简体   繁体   English

SAPUI5 ValueHelpDialog 单元格为空

[英]SAPUI5 ValueHelpDialog Cells Empty

I'm very new to coding and to StackOverflow.我对编码和 StackOverflow 非常陌生。 I'm trying to create a sapui5 Value Help Dialog ( class sap.ui.comp.valuehelpdialog.ValueHelpDialog ) that is supposed to end up filtering search requests from a user table in the SAP backend service.我正在尝试创建一个 sapui5 值帮助对话框( class sap.ui.comp.valuehelpdialog.ValueHelpDialog ),它应该最终过滤来自 SAP 后端服务中用户表的搜索请求。

Right now, I can't even get it to display my mockdata properly.现在,我什至无法让它正确显示我的模拟数据。 The mockdata consists of a "Personen.json" with an array of users with the following fields like this example snippet:模拟数据由一个“Personen.json”和一个用户数组组成,这些用户具有以下字段,例如这个示例片段:

    [{
    "BewId": "2123456789",
    "Posno": 1,
    "PNumber": "P87879876",
    "Firstname": "Heinz",
    "Company": "Some company",
    "IsIntern": true,
    "Lastname": "Wolff"
}, {
    "BewId": "2123456789",
    "Posno": 2,
    "PNumber": "P23498711",
    "Firstname": "Karl",
    "Company": "some company",
    "IsIntern": true,
    "Lastname": "Schmidt"
}]

I've tried almost anything I can think of:我已经尝试了几乎所有我能想到的:

  • Putting literal values instead of the bindings in the text field of the cells.在单元格的文本字段中放置文字值而不是绑定。
  • Using getTableAsync().then instead of getTable() .使用getTableAsync().then而不是getTable()
  • Various different paths including the full path through the entire folder tree and /Personen (which doesn't make sense with the current structure of the JSON I don't think).各种不同的路径,包括整个文件夹树和/Personen的完整路径(我认为这与 JSON 的当前结构没有意义)。
  • using bindRows() instead of bindAggregation() .使用bindRows()而不是bindAggregation()
  • Creating a normal table on the root view with sap.m.Table instead of sap.ui.table.Table (which is the type of the internal table of the ValueHelpDialog as far as I can tell).使用sap.m.Table而不是sap.ui.table.Table在根视图上创建一个普通表(据我所知,这是 ValueHelpDialog 的内部表的类型)。 This displayed the data without problems.这显示数据没有问题。
  • Changing the syntax of my Personen.json to have a single collection within it Personen and changing the path to /Personen in the binding function.更改我的 Personen.json 的语法以在其中包含单个集合Personen并在绑定 function 中更改/Personen的路径。
  • Following the example from the sample as closely as possible.尽可能地遵循示例中的示例
  • Defining the column structure in the controller with addColumn() instead of defining it in a model as I have it now:使用addColumn()在 controller 中定义列结构,而不是像现在这样在 model 中定义它:

     "columnModel.json" {cols": [ { "label": "{i18n>pNumber}", "template": "{PNumber}" }, { "label": "{i18n>firstname}", "template": "{Firstname}" }, { "label": "{i18n>lastname}", "template": "{Lastname}" }]}

Bellow is the event handler function for the value help press in my main view controller:波纹管是事件处理程序 function 在我的主视图 controller 中按值帮助:

    handleValueHelp: function () {
            var oColModel = this.getView().getModel("columnsModel");
            var oUserModel = this.getView().getModel("userModel");
            this._oValueHelpDialog = sap.ui.xmlfragment("appName.view.ValueHelpPopover", this);
            this.getView().addDependent(this._oValueHelpDialog);

            var oTable = this._oValueHelpDialog.getTable();

            oTable.setModel(oUserModel);
            oTable.setModel(oColModel, "columns");

            var oTemplate = new sap.m.ColumnListItem({
                type: sap.m.ListType.Active,
                cells: [
                    new sap.m.Label({
                        text: "{PNumber}"
                    }),
                    new sap.m.Label({
                        text: "{Firstname}"
                    }),
                    new sap.m.Label({
                        text: "{Lastname}"
                    })
                ]
            });

            if (oTable.bindRows) {
                oTable.bindAggregation("rows", "/");
            }

            if (oTable.bindItems) {
                oTable.bindAggregation("items", "/", oTemplate);
            }

            this._oValueHelpDialog.update();

            this._oValueHelpDialog.open();

        }

My XML view fragment for the ValueHelpDialog:我的 ValueHelpDialog 的 XML 视图片段:

    "ValueHelpPopover.fragment.xml"
    <core:FragmentDefinition xmlns:vhd="sap.ui.comp.valuehelpdialog" xmlns:core="sap.ui.core" xmlns="sap.m">
<vhd:ValueHelpDialog id="valueHelp" title="{i18n>valueHelpTitle}" ok=".onValueHelpOkPress" cancel=".onValueHelpCancelPress"
    afterClose=".onValueHelpAfterClose" key="Firstname" descriptionKey="Lastname"></vhd:ValueHelpDialog>

Currently, I'm not getting any error messages, but I'm getting this output: https://ibb.co/q58sk1V When I select the rows, I can tell from the key that they are objects from my mock json odata model, but the cell text is still blank. Currently, I'm not getting any error messages, but I'm getting this output: https://ibb.co/q58sk1V When I select the rows, I can tell from the key that they are objects from my mock json odata model ,但单元格文本仍为空白。

I want the binded values PNummer, Firstname, Lastname to show up in the cells as shown in the template.我希望绑定值 PNummer、Firstname、Lastname 显示在单元格中,如模板中所示。

Things I want to try but haven't gotten the chance yet or can't figure out how:我想尝试但还没有机会或不知道如何尝试的事情:

  • Using the example product collection使用示例产品集合
  • Using a formatter on the bindings to see what actually reaches the cells (my colleague suggested this).在绑定上使用格式化程序来查看实际到达单元格的内容(我的同事建议这样做)。 I haven't been able to figure out how to do this in this situation yet.在这种情况下,我还没有弄清楚如何做到这一点。

Any help would be MASSIVELY appreciated.任何帮助将不胜感激。

Cheers干杯

Add Column to the table then you are able to see the row with actual value in the table.将 Column 添加到表中,然后您就可以在表中看到具有实际值的行。

 var oColumn = new sap.ui.table.Column({
        label: new sap.m.Label({text: "PNumber"}),
        template: new sap.m.Text({text: "{PNumber}"}),
        width: "100px"
});

if (oTable.bindRows) {
        oTable.addColumn(oColumn);
        oTable.bindAggregation("rows", "/");
}

For some reason defining a table in the xml view popover fragment of the Value Help dialog that goes bellow the actual internal table caused the problem to be fixed, even after I removed the table and the code was essentially identical to how it was when it was still not working.出于某种原因,在 xml 视图弹出片段中定义一个表格,该对话框位于实际内部表格下方,导致问题得到修复,即使在我删除表格并且代码基本上与它之前的样子相同之后还是行不通。 Any ideas as to why this was?关于为什么会这样的任何想法? I'm curious to understand this problem.我很想了解这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM