cancel
Showing results for 
Search instead for 
Did you mean: 

issue accessing JSon model property 'items' of table control

0 Kudos

Hi,

I have defined a table in my view.

<Table id="table1" items="{/data}" growing="true" growingThreshold="4">

And i am trying to fetch the property items in the controller as below :

var oModel = this.getView().byId("table1").getModel();

var itemData = oModel.getProperty("/data");

BUT its not working and itemData always remains Undefined .

Could you please help identify what could be wrong here.

Thanks in advance.

Hi Gary,

It should work.

Is data coming in table ?.... Can you share the model structure.

Sample one :

onInit:function(){
this.getView().setModel(new sap.ui.model.json.JSONModel(
{
 "ProductSet": [
                {"Name":"11"}
               ]  
} ));
console.log(this.getView().byId("id_table").getModel().getProperty("/ProductSet"));}

Thanks,

Ajay.

Accepted Solutions (1)

Accepted Solutions (1)

former_member227918
Active Contributor
0 Kudos

in oninit, pass a simple data as well, like below, check this link for your reference

oData = { "data": [] }

var oModel = new JSONModel(oData);

Answers (4)

Answers (4)

karthikarjun
Active Contributor
0 Kudos

Hi Gary,

<Table id="table1" items="{/data}" <!-- this should be forward slash 

Regards,

Karthik Arjun

0 Kudos

Thank You Karthik.

0 Kudos

Also attaching my view code snippet.

0 Kudos

Hi,

I am trying something like this. But not working . ItemData is coming as Undefined and hence

.push throws error. Could you please help.

Thanks in advance.

former_member227918
Active Contributor
0 Kudos

try oModel.getData().data, should work