Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3560

loading a local json file to the Table

$
0
0

Hello,

 

I am using sap.ui.table.table function to display the table and want it to get filled by local data for testing purpose.

I have create the data.json file under folder json.

{

"data":

  [

  {

  "WO": "123456789",

  "Opnumber": "Testing",

  "Object": "Garfield says: I hate Mondays!",

  "Ordtime": "0000",

  "Overtime": "0001",

  "Weekendtime": "0002",

  "Name": "1 People",

  "Completed": "X"

  },

  {

  "WO": "123456789",

  "Opnumber": "Hello",

  "Object": "Garfield says: I hate Tuesdays!",

  "Ordtime": "0003",

  "Overtime": "0004",

  "Weekendtime": "0005",

  "Name": "2 People",

  "Completed": " "

  }

  ]

}

 

Also in the controller, i have written loaded the json file to the Model.

 

//Create instance of JSON model
var oModel = new sap.ui.model.json.JSONModel();

 

// Load Data
oModel.loadData("json/data.json");
// set the model to the core
sap.ui.getCore().setModel(oModel);

 

And finnaly in the VIEW, i have binded the table with "/data". But still the table is empty.

Please let me know what i else i am not doing.

 

here is code snippet of my XML view

<Table id="table2"

rows="/data"

  selectionMode="MultiToggle"

  visibleRowCount="7">

  <toolbar>

.... </toolbar>

...

Displaying columns

....

</Table>


Viewing all articles
Browse latest Browse all 3560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>