cancel
Showing results for 
Search instead for 
Did you mean: 

Model->Table binding doesn't work correctly

Former Member
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Sergey,

Try -


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

      type:"Text",

      enabled:true,

      editable: bCellEditable,

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

});

Regards,

Sai Vellanki.

Former Member
0 Kudos

It's incredible! Thank you! I've been thinking about this error, and everything was so easy!

Answers (1)

Answers (1)

karthikarjun
Active Contributor
0 Kudos

Hi Sergey,

will this help you?

JS Bin - Collaborative JavaScript Debugging

Thanks,

Karthik A

Former Member
0 Kudos

Hi Karthik!

Thanks for the link, I'll look into the code and try to understand my mistakes.

I connected JSONmodel to the component, and you are in the Core ... it is very important?


sap.ui.getCore().setModel(oModel,"oModel");