Search individual filter on standard time failing

Search individual filter on standard time failing

YoDavishYoDavish Posts: 123Questions: 46Answers: 3

Using latest version of editor datatables. I'm using pretty much the same searching filter listed here:

https://datatables.net/examples/api/multi_filter.html

Except mine are on the headers:

    // Apply the search
    tab.columns().every( function () {
        var that = this;

        $( 'input', this.header() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
            }
        } );

        $('input', this.header()).click(function(event) {
            event.stopPropagation();
        })
    } );

On my table server page I've converted one column from military time to standard time using this code:

Field::inst('createdTime')
->getFormatter( Format::datetime('Y-m-d H:i:s', 'Y-m-d g:i A') )
->setFormatter( Format::datetime('Y-m-d g:i A', 'Y-m-d H:i:s') )

However, when I try to perform a search such as "1:46" it does not find a row, unless I use military time "13:46". I've looked at the data being returned by the table server and it's in standard time. Am I missing something?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin
    Answer ✓

    I'm going to guess you are using server-side processing? If so, then that's the issue - the search is being performed by the SQL server - and thus on the raw data.

    One option to address that is to use a VIEW. Use the SQL database's FORMAT function to convert the 24h time to 12h format as part of the VIEW and you can then query against that.

    Or if you don't need server-side processing, don't use it (i.e. less than tens of thousands of rows).

    Allan

This discussion has been closed.