Any idea to manipulate date conversion in grid to show Buddhist ERA - Forum - Rollbase - Progress Community

Any idea to manipulate date conversion in grid to show Buddhist ERA

 Forum

Any idea to manipulate date conversion in grid to show Buddhist ERA

This question has suggested answer(s)

Hi,

From Rollbase 4.0.3.2 , how can customize Kendo UI grid to display date value from AD to Buddhist ERA

Eg.

AD -->  Buddhist. (Conversion made by plus 543 to Year) 

03/31/2016  --> 03/31/2559

TIA,

Tawatchai.

All Replies
  • Hi Tawachai,

    Is your use case is to just display records?  Or includes any further processing?

    -Mani

  • Make trigger on field of date (Either On Create or On Update), then add required value in Date.

  • Hi Mani,

    For Display only. But , to store on Database , we must use AD. Because all DAtabase didn't support Buddhist Year stored.

  • If you want this to be applied on all formatted dates on a page, you can employ a client-side override. Add a script component (at the top of the page containing ListView i.e. Grid component OR for all application pages add to custom header), as follows:

    <script>

    //manipulate dates i.e. +543 years

    rb.newui.util.origformatDate = rb.newui.util.formatDate;

    rb.newui.util.formatDate = function(date,useFullDate){

     if(!rb.newui.util.isDate(date)){

    // null or invalid date

    return "";

    }

     date.setFullYear(date.getFullYear()+543);

     return rb.newui.util.origformatDate(date,useFullDate);

    };

    </script>  

    Note: This will only manipulate display values for Dates.

    Regards,
    Siraj.
  • Hi Siraj,

    Thank you. it work well when I put the code into individual page.

    But din't work when I add to custom header.  How can I debug this.

    PS: where can I learn more about rb.newui.xxxxx command. eg. If I would like change format display from mm/dd/yyyy to dd/mm/yyyy from this command, is it possible to do ?

     From Rollbase user guide , I could not find it.

    Regards,

    Tawatchai

  • For all application pages, can you please add it to custom sidebar (App Settings -> Custom Sidebar). Ideally, it should also work when added as custom header. However, there seems to be an issue around it which will be resolved in the forthcoming releases.

    Shortly, will also share details for taking date inputs on client-side in Buddhist calendar (i.e. form pages). However, on form submit, Rollbase will still process them as Gregorian Calendar date inputs. That is, we will only  target  a client-side customization..

    Regards,
    Siraj.
  • Hi Siraj,

    I'm waiting for your share detail about date input (Buddhist).

    And May I know how can we override date format from client-side.

    TIA.

  • For Client-side customizations for Buddhist calendar, there are two aspects to consider.

    One is, translating all date literals that are displayed on page as per Buddhist calendar.

    Second is ability to enter Buddhist Calendar dates in Rollbase form pages.

    For the first, have already shared a solution. Can you please confirm that the code snippet shared earlier works well across all application pages when added as a Custom Sidebar.

    For the second, still need to work it out. Request you to reach out to Rollbase Technical Support & file an RFA for the same. This way we will be able to better assist you on this requirement. Also, we may need to have Screen sharing sessions while working on & sharing a solution.

    Regards,
    Siraj.
  • We have made available multiple files (js and css) in uncompressed format so that you can learn directly from source code (and in case of CSS, you can learn which css rules to override).
    We have started to document all of this: start from documentation.progress.com/.../
     
    I’ll ask our doc person to respond with more details as multiple utility function have been documented.
     
    Thierry.
     
  • Hi Siraj,

    For the first,  the code that you share, I put into "Custom Sidebar" to apply to all page.  It works very well on field that has date only. But for field that show date time, it didn't apply.  

    one more requirement on this, it's about date format. We need to show format as 'dd/mm/yyyy'. But currently format display still 'mm/dd/yyyy'. From current version ,I cannot use Thai localization to default display it. Because it has  to it has pending defect # 35800.  Is there any way to override localization sformat setting ?  

    Pleas see attach image below.

     

    for the second, I got your tech support ticketing. And if you would like to have more requirement, please feelf ree to contact direct to me.

    Regards,

    Tawatchai. 

  • Thanks for the confirmation.

    Yes, we need to enhance the scripting solution to make it work for DateTime fields as well. Please use the following script in Custom Sidebar for both Date & DateTime field types:

    <script>

    //manipulate dates i.e. +543 years

    rb.newui.util.origformatDate = rb.newui.util.formatDate;

    rb.newui.util.formatDate = function (date, useFullDate) {

     if (!rb.newui.util.isDate(date)) {

       // null or invalid date

       return '';

     }

     date.setFullYear(date.getFullYear() + 543);

     return rb.newui.util.origformatDate(date, useFullDate);

    };

    //manipulate dates i.e. +543 years

    rb.newui.util.origformatDateTime = rb.newui.util.formatDateTime;

    rb.newui.util.formatDateTime = function (date, useFullDate) {

     if (!rb.newui.util.isDate(date)) {

       // null or invalid date

       return '';

     }

     date.setFullYear(date.getFullYear() + 543);

     return rb.newui.util.origformatDateTime(date, useFullDate);

    };

    </script>

    Note: This will affect all application pages & not just the list view (i.e. grid).

    Next, for the form pages, as stated earlier will work out a solution & revert back to your Support Ticket shortly.

    Regards,
    Siraj.
  • Hi Siraj,

    From your last code is working fine both Date and DateTime field in Grid as shown in attached .

    But, on view page the date field  and on audit trail page date time field didn't convert to Buddhist era as expected.

    View page:

    View Audit Trail Page:

    How can we fix this ?

    Regards,

    Tawatchai

  • Hi Thierry,

    Thank you for your information.

    Regards,

    Tawatchai

  • Hi Siraj,

    Please se my post on Posted by tawatchai

    on 11 Mar 2016 10:47.  How can I make current code  impact to other page (View page and Audit trail page).

    TIA,

    Tawatchai

  • The solution should work on all application pages i.e. list page as well as view page.

    Can you make this change for the script component that you are adding to Custom Sidebar:

    <script id="executeBeforeUIStarts">

    //Add id attribute as stated above.

    This will ensure that the script modifications are always picked up, even when you are navigating from one page to another with Ajax based navigation Turned ON.

    Regarding Audit Trail page, this is one place where it will not work. Even in NUI pages, there are some cases like Audit Trail wherein we embed HTML generated on server side directly into the page. As our solution is basically as client-side solution, it will not be able to transform the Date literals as per Buddhist Calendar for such cases.

    Regards,
    Siraj.