cancel
Showing results for 
Search instead for 
Did you mean: 

Add hard-coded text in formatter sap ui5

Former Member
0 Kudos

Hi Experts

                 i am using formatter in util folder to convert the date in a valid form. Now date is coming in red circle area. But I want to write text(delivered date : 25 September 2015) .So how can i write text before date..

I am also share my code..

Please help me out

thanks

Vishnu

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor
0 Kudos

Hi Vishnu,

Try -


text: "Delivered Date : "+{

  path:"OrderDate",

  formatter: com.vikalp.dealermgmt.util.Formatter.OrderDate

  }

If you're using localization for hard coded text, then you can make use of parts. Check this thread for more info -


Regards,

Sai Vellanki.

former_member182862
Active Contributor
0 Kudos

another way to do this is

text: {
  parts: ["i18n>deliverydate", "OrderDate"],
  formatter: function(i18nString, orderDate) {
     return i18nString.replace('{0}', com.vikalp.dealermgmt.util.Formatter.OrderDate.call(null, orderDate));
  }
}
// assuming that your have i18n as the resource model
// deliverydate=Delivered Date: {0}
text: {
  path: "OrderDate",
  formatter: function(orderDate) {
     return 'Delivered Date: ' + com.vikalp.dealermgmt.util.Formatter.OrderDate.call(null, orderDate);
  }
}

I prefer the first approach for building enterprise software, we need to have localization of text

Thanks

-D

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

I want to decolour the hard-code text Overall Status.?

how can it be possible??

I am going to attach my code.

  firstStatus:[

                     {

                      text :"OverallStatus:  {OverallStatus}",

                      state: {

                      path:"OverallStatus",

                      formatter:function(id)

              {

              if(id == "Completely proc")

              {

              return "Success"

              }

              if(id=="Not yet process")

              {

              return "Error"

              }

              if(id=="Partially proce")

              {

              return "Warning"

              }

              } }

thanks and regards

Vishnu