Skip to Content
0

Unable to bind to sap.ui.table in sap.ui.comp.valuehelpdialog

Feb 08, 2017 at 04:42 PM

76

avatar image

Hi all,

im learning to use value help dialog and trying with a simple example but im unable to bind to table element in the valuehelp dialog. i believe its a minor mistake with binding as the ui5 plugin in chrome shows the binding context in sap.ui.table.Row. The table opens blank

here is the code

var names = [ {firstname:"Radhesh", lastname: "Shinde",location:"Mumbai"}, {firstname:"Vighnesh", lastname: "Kamath",location:"Pune"}, {firstname:"Archit", lastname: "Wahi",location:"Nagpur"} ];

abc: function(){

var inp = new sap.ui.comp.valuehelpdialog.ValueHelpDialog({ title: "Company", });

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

var table = inp.getTable(); table.setModel(model);

console.log(model);

var col1 = new sap.ui.table.Column({ label:"firstname" });

table.addColumn(col1);

var col2 = new sap.ui.table.Column({ label:"secondname" });

table.addColumn(col2);

var col3 = new sap.ui.table.Column({ label:"location" });

table.addColumn(col3);

//table.bindAggregation("rows","/");

table.bindRows("/");

console.log(table.hasModel());

inp.open();

}

Please provide input.

Many thanks

Archit Wahi

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Srikanth KV Feb 08, 2017 at 06:06 PM
1

There is no template available for the column to load the data, use below code for the columns

var col1 = new sap.ui.table.Column({ 
                           label:"firstname", 
                           template:  new sap.m.Text({text: "{firstname}" })    //bind template to fisrtname
                           });
table.addColumn(col1);

var col2 = new sap.ui.table.Column({ label:"Second name", template: new sap.m.Text({text: "{secondname}" }) //bind template to secondname in model });
table.addColumn(col2);
var col3 = new sap.ui.table.Column({ label:"location", template: new sap.m.Text({text: "{location}" }) //bind template to location in model });
table.addColumn(col3);

Share
10 |10000 characters needed characters left characters exceeded