Skip to Content
avatar image
Former Member

Add hard-coded text in formatter sap ui5

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 19, 2015 at 07:34 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • avatar image
    Former Member
    Oct 19, 2015 at 09:32 AM

    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


    Add comment
    10|10000 characters needed characters exceeded