Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Model->Table binding doesn't work correctly

Dear colleagues,

please help me with this UI5 problem.


I created a JSON model and bind it to my Component.

Then I receive this JSON model in my View that is binded to the same Component.

All JSON data except the table data is received correctly.

But table data does not received from JSON to View.

Here are my code:

(Component.js)

...

var main_source_model = new JSONModel();

var module_patch = jQuery.sap.getModulePath("sap.ui.x5.forms", "/json/TableData.json");

main_source_model.loadData(module_patch, "", false);

this.setModel(main_source_model, "main_source");

...

(TableData.json)

{

     "output":{

          ...

          "groups":[

               {

                    ...

                    "lines":[ ... ]

                    ...

               }

            ]

     }

}




(MultiTable.view.js)


DFC.output.groups.forEach(function(group, i){

       if(group.edit == "X") bCellEditable = "{settings>/edit_tables}";

       else bCellEditable = false;

       aTblColumns = [];

       aTblCells = [];

       DFC.output.columns_short.forEach(function(column, j){

       aTblColumns[j] = new sap.m.Column({

            header: new sap.m.Label({text: "{main_source>/output/columns_short/"+j+"/name}"})

       });

       aTblCells[j] = new sap.m.Input({

            type:"Text",

            enabled:true,

            editable: bCellEditable,

            value: "{"+column.id+"}"

       });

  });

  aTblColumns[0].setWidth("10px").setHAlign(sap.ui.core.TextAlign.Center);

  ColListItems[i] = new sap.m.ColumnListItem({cells: aTblCells});

  aGroupTables[i] = new sap.m.Table({

       columns:[aTblColumns],

  });

//====================================================================================

aGroupTables[i].bindAggregation("items", { path: 'main_source>/output/groups/'+ i +'/lines', template: ColListItems[i] });

//====================================================================================

  aGroupPanels[i] = new sap.m.Panel({

       headerText: "{main_source>/output/groups/"+i+"/name}",

       expandable: true,

       expanded: true,

       backgroundDesign: sap.m.BackgroundDesign.Transparent,

       content: [

               new sap.m.Label({text: "{main_source>/output/groups/"+i+"/name}"}), //There is displayed correctly

               aGroupTables[i]

       ]

  });

  });


In the end, I see the table. It has a line, but they are empty ... what am I doing wrong?

001.png (10426 B)
Tags:
Former Member
replied

Hi Sergey,

Try -

aTblCells[j] = new sap.m.Input({

      type:"Text",

      enabled:true,

      editable: bCellEditable,

      value: "{main_source>"+column.id+"}"

});

Regards,

Sai Vellanki.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question