Skip to Content
0
Former Member
Sep 23, 2014 at 09:50 AM

Supply dataset in dynamic way

20 Views

Hi,

I would like to supply dataset in dynamic way.

I have a array (dataset_metadata) which contains metadata but I don't know how many metadata are in. I just know that the last metadata is the measure.

So can you help me to supply dataset in javascript?

For 3 metadata, the code is:

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

dimensions : [

{ axis : 1, name : dataset_metadata[0]["$"], value : "{" + dataset_metadata[0]["$"] + "}" },

{ axis : 2, name : dataset_metadata[1]["$"], value : "{" + dataset_metadata[1]["$"] + "}" }

],

measures : [

{ name : dataset_metadata[2]["$"], value : '{' + dataset_metadata[2]["$"] + '}' }

],

data : { path : "/data" }

});

For x metadata, with a loop, the code is?

-----

Same question for the table:

var oTable = new sap.ui.table.Table({

columns : [ new sap.ui.table.Column({

label : dataset_metadata[0]["$"],

template : new sap.ui.commons.TextView({

text : '{' + dataset_metadata[0]["$"] + '}'

}),

sortProperty : dataset_metadata[0]["$"],

filterProperty : dataset_metadata[0]["$"],

width : "100px"

}), new sap.ui.table.Column({

label : dataset_metadata[1]["$"],

template : new sap.ui.commons.TextView({

text : '{' + dataset_metadata[1]["$"] + '}'

}),

sortProperty : dataset_metadata[1]["$"],

filterProperty : dataset_metadata[1]["$"],

width : "100px"

}), new sap.ui.table.Column({

label : dataset_metadata[2]["$"],

template : new sap.ui.commons.TextView({

text : '{' + dataset_metadata[2]["$"] + '}'

}),

sortProperty : dataset_metadata[2]["$"],

filterProperty : dataset_metadata[2]["$"],

width : "100px"

}) ],

rows : "/data",

visibleRowCount : 12

});

How supply oTable with using a loop?

Best regards

Yannick