Forum Stats

  • 3,741,291 Users
  • 2,248,405 Discussions
  • 7,861,728 Comments

Discussions

ojet 12 hours date time table sorting issue

User_XQLJ4
User_XQLJ4 Member Posts: 3 Employee

Hi,

I need some help in sorting of ojet table with date time(12 hours format). We are getting problem mostly with 12.00 AM recordings, in descending order every time 12.00 AM recordings is shown first and then 2.00 AM . It should be other way round since its a descending order. Before providing data to table everything is sorted properly in JS, but looks like ojet internally applies its own sort . If its 24 hours format everything works perfectly fine.

Any one has any idea regarding this issue then please suggest some solution

Thanks

Answers

  • John 'JB' Brock-Oracle
    John 'JB' Brock-Oracle Posts: 2,582 Employee
    edited Apr 8, 2021 2:51PM

    What version of JET?

    What does the HTML for the oj-table definition look like?

    What does the JS look like that is associated with the table?

    Can you reproduce this using the JET Cookbook by chance?

  • User_XQLJ4
    User_XQLJ4 Member Posts: 3 Employee

    Hi,


    Sorry for the late reply. Ojet version is 8.3.0

    response data for the table is constructed from the result coming from the server side and hence the data source we construct and provide it in the form of array



            <oj-table id='recordings_table' aria-label='Recordings Data'

                data='[[datasource]]'  as='cell'

                data-bind="click: currentTableRowListener" 

                selection = '{{selectedItem}}'

                display='grid'

                on-oj-sort='[[sortListner]]'

                selection-mode='{"row": "single"}'

                columns='{{columnArray}}'

                columns-default='{"headerTemplate": "headertemplate"}'

                style='width: 100%;'

                hasFocus= 'true'>

                <!--<template slot="headertemplate">

                        <span class="column-header" data-bind="text: cell.data"></span>

                </template>-->

                <oj-paging-control id="paging" data='[[datasource]]'  page-size='[[pageSize]]' slot='bottom' data-bind="click: pageChangedInvoked" page-options.layout='[[pageOptions]]'>

                </oj-paging-control>

            </oj-table>

            

  • User_XQLJ4
    User_XQLJ4 Member Posts: 3 Employee

    Hi,

    Happy to announce that finally I could solve this issue . It just needed different thought process to think. Basically server side response of date will always be in the string format.

    So I changed the string to date using java scripts new Date() function but again it was showing date in the GMT format I needed to show it in the proper format so had to wrap my head around the display part . so best solution was using the sortProperty field of the table array . Here is how my column array looks like .

    datetype_time = new Date('time_in_string_format')

    self.columnArray.push({"headerText": app.getLocales('recordings.columns.time'),"field": ''time", sortable": "enabled","sortProperty": "datetype_time"});


    so while sorting it will take proper care of sorting the date, date wise and not string wise where as display wise it will show it in string

Sign In or Register to comment.