cancel
Showing results for 
Search instead for 
Did you mean: 

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

archit_wahi
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member365727
Active Contributor

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);

Answers (0)