Skip to Content
author's profile photo Former Member
Former Member

The table filling does not work

Hello!

I need help.

I have a dialog window (sap.ui.xmlfragment). In this window I create a JSON model:

  var PositionsSPD = new JSONModel({
  items: []
  });
  this.getView().setModel(PositionsSPD, "PositionsSPD");

In view:

  <m:Table id="lineSPDTableId" 
  ....
     items="{path: 'PositionsSPD>/items'}">
  <m:items>
  <m:ColumnListItem type="Active">
  <m:cells>
  <m:Text text="{PositionsSPD>DocNumExt}" width="auto" maxLines="2" wrapping="true" textAlign="Begin" textDirection="Inherit"/>
  <m:Text text="{PositionsSPD>DocDate}" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/>
  <m:Text text="{PositionsSPD>DocTypeCode}" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/>
  <m:Text text="{PositionsSPD>Intpodnum}" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/>
  <m:Text text="{PositionsSPD>Extcnum}" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/>
  </m:cells>
  </m:ColumnListItem>
  </m:items>

In method that work after button click I have an array with the test data:

  var PositionsSPD = this.getView().getModel("PositionsSPD");
  var oPositionsSPDData = PositionsSPD.getData();
  console.log(oPositionsSPDData);
  var oPositionsItems = oPositionsSPDData.items;

  oPositionsSPDData.items[0] = {"DocNumExt": "11111",
               "DocDate": "222222",
               "Extcnum": "5555",
               "DocTypeCode": "33333",
               "Intpodnum": "444444"};

  oPositionsSPDData.items[1] = {"DocNumExt": "6666",
               "DocDate": "77777",
               "Extcnum": "8888",
               "DocTypeCode": "99999",
               "Intpodnum": "0000"};

  PositionsSPD.setData(oPositionsSPDData);
  console.log(oPositionsSPDData);
  console.log(PositionsSPD.getData());

However, after click the button the data does not appear in the table. In console I get my array. He is ok. refresh() does not help.

When I put the test data in method init() my table is filled.
Why? How can I fill the table after a buton click?

Thanks!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 10, 2016 at 06:36 AM

    Next to this line append the below code.

    Sol1:

    15. PositionsSPD.setData(oPositionsSPDData);


    this.getView().setModel(PositionsSPD, "PositionsSPD");

    or

    this.getView().getModel("PositionsSPD").refresh();


    Sol2:


    Get the table ID and Bind this model to that Table


    Regards,

    Karthik A


    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Karthik A.,
      thanks for the answer!

      this.getView().setModel(PositionsSPD, "PositionsSPD");

      or

      this.getView().getModel("PositionsSPD").refresh();

      It does not help.

      Unfortunately I can not find an example of binding the model to the m:Table that already exists in xml view...

      I write:

        var oTable = this.getView().byId("lineSPDTableId"); 
        oTable.setModel(PositionsSPD);
        oTable.bindItems("/items", new sap.m.ColumnListItem({
                   cells : [ new sap.m.Text({
                       text : "{DocNumExt}"
                   }), new sap.m.Text({
                       text : "{DocDate}"
                   }), new sap.m.Text({
                       text : "{Extcnum}",
                   }), new sap.m.Text({
                       text : "{DocTypeCode}",
                   }), new sap.m.Text({
                       text : "{Intpodnum}",
                   })]
               }));
      

      But it does not work...

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.