ItemTemplate Currency formatting

Dear,
how can I achieve formatting in the ComboBox ItemTemplate?

<ejs-combobox id="comboInvoiceNumber" itemTemplate="<span class='item'>${InvoiceNumber} - ${InvoiceAmount} - ${InvoiceDate}</span>">

In the above example I would like to show InvoiceAmount  as "€12,00" (now it is shown as "12.000")  and InvoiceDate as "17/05/2020" (which is now shown as long date)..

Thanks,
Koen

1 Reply

SN Sevvandhi Nagulan Syncfusion Team May 28, 2020 11:45 AM UTC

Hi Koen, 


Greetings from Syncfusion support. 


You can directly provide the € before the InvoiceAmount to showcase the value.  Also, you can convert the long dates to date by using the custom helper function in the template. Kindly refer the below code, 
 
 
<ejs-combobox id="customers" query="new ej.data.Query().from('Employees').select(['FirstName', 'BirthDate', 'EmployeeID']).take(6)" placeholder="Select a customer" popupHeight="200px" 
                      itemTemplate= "@Html.Raw("<span class='name'>€${FirstName}- ${customHelper(data)}</span>")" > 
            <e-combobox-fields value="FirstName"></e-combobox-fields> 
            <e-data-manager url="https://services.odata.org/V4/Northwind/Northwind.svc/" adaptor="ODataV4Adaptor" crossDomain="true"></e-data-manager> 
        </ejs-combobox> 

    customHelper = function (args) { 
        var getDOMString = ej.base.compile('<span>${upperCase(BirthDate)}</span>', customHelperFunc); 
      let opElem = getDOMString(args); 
      var element = document.createElement('span'); 
      element.appendChild(opElem[0]); 
      return element.innerHTML; 
  } 
    var customHelperFunc = { 
        upperCase: function upperCase(str) { 
            return new Date(str).toLocaleDateString();  
        }  
    }; 

In the above code, the BirthDate fields return as the date object. We passed the date value to the new date and get the dateValue from the object on its own using the LocaleDateString method. 



Regards, 
Sevvandhi N 


Loader.
Up arrow icon