Skip to Content
avatar image
Former Member

Binding Control to JSON Model

Hi everyone. I'm trying to Bind a control to a JSON Model, but doesn't seem to be working:

// Model With Data

var lco_Model = new sap.ui.model.json.JSONModel(

{      Data: [ {      task : "done",

                         value : "10" },

      

                 {          task : "open",

                            value : "20" }      ]

});

  // Statistics Chart

  var lco_Dataset = new sap.viz.ui5.data.FlattenedDataset({

  // dimensions : [ {

  // axis : 1,

  // name : 'Task Status',

  // value : "{task}"

  // } ]

  measures : [ {

  name : 'Qty',

  value : '{value}'

  } ]

  });

  var lco_Dimension = new sap.viz.ui5.data.DimensionDefinition();

  lco_Dimension.setAxis(1);

  lco_Dimension.setName('Task Status');

  lco_Dimension.setValue(('{task}'});

  lco_Dataset.addDimension(lco_Dimension);

  lco_Dataset.bindData("/Data");

It works if I specify the value in the constructor (ie: un-commenting the lines).

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 02, 2015 at 07:26 AM

    Hi Jibran,

    Is there any reason, why you're not creating the measure same like dimension definition using method .addMeasure() of flattenedDataset, try like this and check -

    var oDataset = new sap.viz.ui5.data.FlattenedDataset();
    var oMeasure = new sap.viz.ui5.data.MeasureDefinition({name:"Qty", value:"{value}"});
    oDataset.addMeasure(oMeasure);
    

    Check the sample here: Plunker - VizFrame, I have commented the Constructor code and use chain of methods in the controller.

    Regards,

    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded