cancel
Showing results for 
Search instead for 
Did you mean: 

Data binding using javascript ?

abesh
Contributor
0 Kudos

I was trying to reproduce a similar result if I substitute the Javascript Object Literal notation with Javascript methods and objects for a Pie chart. So I have this :

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

                                                  dimensions : [ {

                                                            axis : 1,

                                                            name : 'Product',

                                                            value : "{Material}"

                                                  } ],

                                                  measures : [ {

                                                            name : 'Quantity',

                                                            value : '{PercQuantity}'

                                                  } ],

                                                  data : {

                                                            path : "/Rowset/Row",

                                                            factory : function() {

                                                            }

                                                  }

                                        });

And the corresponding code I wrote replacing the one above is :

dataset1 = new sap.viz.ui5.data.FlattenedDataset();

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

dimObject.setAxis(1);

dimObject.setName("Product");

dimObject.setValue("{Material}");

dataset1.addDimension(dimObject);

var measObject = new sap.viz.ui5.data.MeasureDefinition();

measObject.setName("Quantity");

measObject.setValue("{PercQuantity}");

dataset1.addMeasure(measObject);

dataset1.bindData("/Rowset/Row", "");

Which seems to not work . Esp. it seems that UI5 fails to interpret this line for the data binding :

dimObject.setValue("{Material}"); & measObject.setValue("{PercQuantity}");

What exactly am I doing wrong ? What is the alternative if I want to do it not the JS Obj Literal notation way ?

Thanks so much

View Entire Topic
GrahamRobbo
Active Contributor
0 Kudos

Hi Abesh,

think I have cracked this. You need to bind the property as follows.

dataset1 = new sap.viz.ui5.data.FlattenedDataset();

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

dimObject.setAxis(1);

dimObject.setName("Product");

dimObject.bindProperty("value","Material");  /* Use this instead of setValue method */

dataset1.addDimension(dimObject);

var measObject = new sap.viz.ui5.data.MeasureDefinition();

measObject.setName("Quantity");

measObject.bindProperty("value","PercQuantity"); /* Use this instead of setValue method */

dataset1.addMeasure(measObject);

dataset1.bindData("/Rowset/Row", "");

Cheers

Graham Robbo