Skip to Content
0

Dynamically Generate columns for ui5 table at the click of the checkbox

Dec 25, 2017 at 08:19 AM

70

avatar image
Former Member

HI Experts,

I am trying to dynamically generate columns once checked in checkbox.Columns are getting added however I am not able to display the label.It has the value undefined.And thus the column are getting generated with out any label. And same with text

var objTable= this.byId("uiTable");
   objTable.bindColumns("selectedModel>/columns/", function(sId, oContext) {
   debugger;
    var oColumnObj = oContext.getObject();
   var  label,text="";
    return new sap.ui.table.Column({
     label :  new sap.m.Label({text: oColumnObj.columKey}),
    });
});
undef.png (28.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

avatar image
Former Member Dec 29, 2017 at 02:40 AM
0

Well you have a typo in your label assignment -

oColumnObj doesn't have `columKey` it has `columnKey`

Try

returnnewsap.ui.table.Column({
     label :newsap.m.Label({text: oColumnObj.columnKey}),});
Share
10 |10000 characters needed characters left characters exceeded
Iftah Peretz
Dec 25, 2017 at 07:07 PM
0

Hi,

Check this blog . It will sort it out for you.

In addition, out of the SDK of class sap.ui.table.Column under aggregations - template(I bolded the interesting part):

Template (cell renderer) of this column. A template is decoupled from the column. Each time the template's properties or aggregations have been changed, the template has to be applied again viasetTemplate for the changes to take effect. If a string is defined, a default text control will be created with its text property bound to the value of the string. The default template depends on the libraries loaded. If there is no template, the column will not be rendered in the table.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member
Dec 29, 2017 at 02:13 AM
0

hi Dfive,

it is clear that label will be undefined. It is not assigned with any value. Please check your code.

is oColumnObj.columnKey correct?

here is simple example to achieve what you have in mind

http://jsbin.com/rexeyaf/1/edit?js,output

Share
10 |10000 characters needed characters left characters exceeded