Skip to Content
0

How to append a constant value to a SAPUI5 table's column value

Dec 21, 2016 at 11:19 AM

100

avatar image
Former Member

Hi all,

I am trying to append constant "1:" to one of the table column values. My table column is :

var oTable = new sap.ui.table.Table({
    selectionMode : sap.ui.table.SelectionMode.Single,    selectionBehavior: sap.ui.table.SelectionBehavior.Row });    oTable.addColumn(new sap.ui.table.Column({
        label: new sap.ui.commons.Label({text: "Rate"}),
        template: new sap.ui.commons.TextField({value: "{RATE}"})
      }));

Now on that above column i am trying to add constant as "1:". But if i try like as shown below, i don't get the desired result.

oTable.addColumn(new sap.ui.table.Column({

            label: new sap.ui.commons.Label({text: "Rate"}),

            template: new sap.ui.commons.TextField({value: "1:"+"{RATE}"})

          }));

I intend to do this change in a clean way if possible? How can i achieve this? Looking forward to your solutions. Thanks in advance

10 |10000 characters needed characters left characters exceeded

Hi Amit,

How about using formatter and to accomplish this something like this:

oTable.addColumn(newsap.ui.table.Column({

            label:newsap.ui.commons.Label({text:"Rate"}),

            template:newsap.ui.commons.TextField({value: 

                                                { path: "RATE",formatter: function(val){ return "1" + val;}}})}));


Hope this helps
0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Jun Wu Dec 21, 2016 at 05:30 PM
3
 template:newsap.ui.commons.TextField({value:"1:{RATE}"})

give it a try

Share
10 |10000 characters needed characters left characters exceeded
Sergio Guerrero Dec 22, 2016 at 08:20 PM
0

i second Jun Wu approach.. normally when you use data binding you would use ...

"{YOUR_PROPERTY}" unless you have a named model

"{NAMED_MODEL>/YOUR_PROPERTY}" and you can use constant values next to it as Jun Wu showed before

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Dec 29, 2016 at 02:35 PM
0

Create additional attribute in your model and bind that model to the elements.

myModel[0].NewRate = "1:"+myModel[0].Rate;

and then the mapping will look something like

 template: new sap.ui.commons.TextField({value: "{NewRate}"})
Share
10 |10000 characters needed characters left characters exceeded