Skip to Content

how to bind rows with dynamic json data?

I have tried this

var oTable= this.getView().byId("tstable");

var date= this.getView().byId("DP1").getValue();

var to = this.getView().byId("to").getValue();

var typ = this.getView().byId("typ").getValue();

var frm = this.getView().byId("frm").getValue();

var prj = this.getView().byId("prj").getValue();

var des = this.getView().byId("des").getValue();

var jModel= new sap.ui.model.json.JSONModel();

var data = {d: {

date: date,

from: "",

to: "",

type:typ,

customer: "",

project: "",

internal: "",

description: "" }};

jModel.setData(data);

oTable.setModel(jModel);

oTable.bindRows("/data"); },

////////////////////

the error in the console is "oTable.bindRows is not a function"

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 13, 2017 at 01:48 PM

    Is this sap.m.Table or sap.ui.table.Table?

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 14, 2017 at 02:56 AM

    You must be using the sap.m.table. You need to use bindItems and not bindRows.

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 13, 2017 at 04:06 PM

    uhm, your JSon is not rigth, it is not an Array ;) Furthermore, the path on your Binding is wrong it should be this :

    oTable.bindRows("/"); },

    If you do not want to modify your binding, your JSon should be this :

    { data : [ { date : '', from : '', ...}, { date : '', from : '', ...}, ... ]}

    Regards,

    Add comment
    10|10000 characters needed characters exceeded