Set locale of buddhist year in Grid

Hello,

             Is there anyway to show Thai buddhist year (gregorian year + 543 e.g. 2021 + 543 so, Thai buddist year will be 2564) in Grid and export it into excel and pdf file? So far I tried setting locale as shown below but it doesn't work.

                 <ejs-grid id="Grid" dataSource="ViewBag.DataSource" allowGrouping="true" allowFiltering="true" locale="th-TH" allowPaging="true">

             
            If locale doesn't support Thai buddhist year. Is there anyway to change value cell in grid when it render? So, I might use javascript (toLocaleDateString('th-TH') command) instead.
 
Thanks in advance,
Ray

1 Reply 1 reply marked as answer

BS Balaji Sekar Syncfusion Team January 20, 2021 07:41 AM UTC

Hi Sirapet, 
 
Thanks for your valuable patience. 
 
Currently we do not have support for Thai Buddhist locale in our DataGrid component however we can include the Date value with 543 years using queryCellInfo, excelQueryCellInfo and pdfQueryCellInfo events. 
 
Using queryCellInfo, we have added year value with 543 years in the OrderDate column it will update in the Grid UI alone. 
 
In excelQueryCellInfo and pdfQueryCellInfo event, we have included 543 years in the OrderDate value while exporting excel and pdf. 
 
Please refer the below code example for more information. 
[index.cshtml] 
 function queryCellInfo (args) { 
    if (args.column.field == "OrderDate") { 
      debugger; 
      var updateYr = args.data["OrderDate"].getUTCFullYear() + 543; add the 543 year in OrderDate value 
      args.data["OrderDate"].setFullYear(updateYr);   // Assign that year value into OrderDate 
    } 
  }, 
 function excelQueryCellInfo(args) { 
    if (args.column.field == "OrderDate") { 
      var updateYr = args.data["OrderDate"].getUTCFullYear() + 543; 
      args.data["OrderDate"].setFullYear(updateYr); 
    } 
  } 
  function pdflQueryCellInfo(args) { 
    if (args.column.field == "OrderDate") { 
      var updateYr = args.data["OrderDate"].getUTCFullYear() + 543; 
      args.data["OrderDate"].setFullYear(updateYr); 
    } 
  }, 
 
 
                                                https://ej2.syncfusion.com/documentation/api/grid/#pdfquerycellinfo  
                                                https://ej2.syncfusion.com/documentation/api/grid/#excelquerycellinfo  
 
Please get back to us, if you need further assistance. 
 
Regards, 
Balaji Sekar 


Marked as answer
Loader.
Up arrow icon