【问题标题】:Application with SmartTable and JSONModel binding具有 SmartTable 和 JSONModel 绑定的应用程序
【发布时间】:2017-05-01 20:32:04
【问题描述】:

我正在尝试使用带有 json 模型绑定的智能表开发 SAPUI5 应用程序。 While running this program I'm getting error I'm sharing that snapshot with you 我正在分享我的代码,请建议我如何实现这一目标

在视图中:

<smartTable:SmartTable 
        id="smartTable_ResponsiveTable"
        smartFilterId="smartFilterBar" 
        tableType="ResponsiveTable" 
        editable="false"
        entitySet="tableSet"
        useVariantManagement="false"
        useTablePersonalisation="false" 
        header="Products" 
        showRowCount="true"
        useExportToExcel="false" 
        enableAutoBinding="true"
        initiallyVisibleFields="name">
    </smartTable:SmartTable>

在控制器中:

var array = [{
                "name" : "Dinesh",
                "id" : "123"
            },
            {
                "name" : "Nikhil",
                "id" : "456"
            },{
                "name" : "Pulkit",
                "id" : "789"
            }];
            var model = new sap.ui.model.json.JSONModel();
            model.setData({
                tableSet: array
            });
            this.getView().byId("smartTable_ResponsiveTable").setModel(model);
            });

请建议我如何做到这一点。

【问题讨论】:

    标签: sapui5


    【解决方案1】:

    无法将 jsonData 模型绑定到智能表。智能表上的列/行是基于 odata 服务的 metadata.xml 定义的。

    检查这个:https://answers.sap.com/questions/90310/application-with-smarttable-and-jsonmodel-binding.html

    【讨论】:

      【解决方案2】:

      如果您尝试在视图中定义列,您会得到什么?

      <smartTable:columns>                        
      (your columns)                  
      </smartTable:columns>
      

      问候, 加布里埃尔

      【讨论】:

      • 嗨加布里埃尔,感谢您的回复。我在我的代码中添加了列标记,如下所示 添加后,我收到以下错误,无法从sapui5.netweaver.ondemand.com/resources/sap/ui/comp/smarttable/… 加载“sap/ui/comp/smarttable/columns.js”: 404 - 错误。请说出问题所在并说明如何在其中添加列(请提供示例代码)问候,Dinesh
      • explored 上的示例未定义 xml 视图中的列,因此我无法快速知道是否可行。唯一的一个建议是尝试遵循探索中的示例:
      • 好的 Gabriel,我会尝试,但我认为这是实体集问题,因为与 Northwind odata 服务模型相同的 UI 工作正常,但这里我尝试使用 json 模型,但不是 json 模型显示结果。关于如何将 json 模型设置为智能表的任何想法
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-06
      • 2016-12-28
      • 2013-12-18
      • 2017-10-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多