Kirit Modi
Kirit Modi

Reputation: 23407

Add specific text in table binding value in sapui5 using sap.m.Table

I am trying to develop an SAPUI5 app but I can't add a specific text before the value in a table column.

onInit : function() {
  var oModel = new sap.ui.model.json.JSONModel('add json file ');
  sap.ui.getCore().setModel(oModel,'products');
}

In the View I am creating a table and binding all records:

var oTable = new sap.m.Table("productsTable",{
            inset: true,
            columns: [
                      //image
                     new sap.m.Column({
                         hAlign: "Left",
                         width: "100px",

                         demandPopin: true,
                         popinDisplay: "Block",
                         minScreenWidth: sap.m.ScreenSize.Medium
                     }),

            ]
        });

var oTemplate = new sap.m.ColumnListItem({
            type: sap.m.ListType.Active,
            cells: [
                      new sap.m.Text({
                        text: "Title :{products>description} ",

                        //visible :false,
                    }),

            ]
        });

oTable.bindAggregation("items","products>App",oTemplate);  // Here bind all record
return new sap.m.Page({
            title: "App Name",
            content: [oTable],
            showNavButton: true,
            navButtonPress: function() {
                oController.navigation();
                            },
            footer: new sap.m.Bar({
                contentLeft: [
                              new sap.m.Text({text: "Smart",})
                ]
            }),

        });

My desired output is:

enter image description here

But it's displayed this way:

enter image description here

Upvotes: 0

Views: 1276

Answers (2)

solrac
solrac

Reputation: 629

Try add slash (/) caracter before the property.

Sample:

"Title :{products>/description} "

OR

Maybe your binding is incorrect, try this

...
text: {  path: "{products>/description}", //with or without slash (/)
         
         formatter: function(desc) {
            return "Title" + desc;
        }                                
   }                          
...

Upvotes: 0

hirse
hirse

Reputation: 2412

As @Qualiture said in the comment this looks like you need to enable the complex binding syntax.

You can do that by setting the binding syntax mode explicitly using
data-sap-ui-bindingSyntax="complex" or implicitly by specifying the compatibility version of 1.26 or edge: data-sap-ui-compatversion="edge".

Upvotes: 2

Related Questions