代码之家  ›  专栏  ›  技术社区  ›  rs9

获取“omodel.read不是函数”错误

  •  1
  • rs9  · 技术社区  · 6 年前

    在对 v4 odataModel执行读取操作时,我收到一个错误消息,说

    < Buff行情>

    omodel.read不是函数

    < /块引用>

    代码

    错误

    如果我做错了,请告诉我如何改正。

    代码

    Model declaration

    误差

    Error screenshot

    如果我做错了,请告诉我怎么改正。

    2 回复  |  直到 6 年前
        1
  •  2
  •   Nandan Chaturvedi    6 年前

    应出现此错误。

    OData模型v4中不存在读取方法。

    见下文: read is not a function in V4

    但是,您可以对OData v2执行相同的操作(建议使用OData的方法,因为v4仍然缺少一些功能)

    Restrictions with oData V4

    oData V2 vs oData V4

    不过,如果稍后需要将响应项与表绑定,则可以 这样做:

    var oModel = new sap.ui.model.odata.v4.ODataModel({
        groupId: "$auto",
        serviceUrl: "url",
        synchronizationMode: "None",
        operationMode: "Server"
      }),
      oSettings = new sap.ui.model.json.JSONModel({
        bOnlyLarge: false,
        bFilterGermany: false
      });
    var oTable = new sap.ui.table.Table({
      columns: [{
        label: "ProductName",
        template: new sap.m.Text({
          text: "{Country}"
        }),
        sortProperty: "ProductName"
      }]
    });
    oTable.setModel(oModel);
    
    oTable.bindRows({
      path: "/Products"
    });
        2
  •  0
  •   jasbir    6 年前
    var oModel = new sap.ui.model.odata.v4.ODataModel({
        /* send requests directly. Use $auto for batch request wich will be send automatically on before rendering */
      groupId : "$direct",
        /* I'll just quote the API documentary:
      Controls synchronization between different bindings which refer to the same data for the case data changes in one binding.
      Must be set to 'None' which means bindings are not synchronized at all; all other values are not supported and lead to an error.
      */
      synchronizationMode : "None",
      /*
      Root URL of the service to request data from.
      */
        serviceUrl : "http://services.odata.org/TripPinRESTierService/",
      /*
      optional. Group ID that is used for update requests. If no update group ID is specified, mParameters.groupId is used.:
      updateGroupId : "$direct"
      */
      });