How to search on rendered data with server side

How to search on rendered data with server side

raf_mixraf_mix Posts: 12Questions: 3Answers: 0
edited December 2021 in Free community support

Hi,
I use dates on a column. The dates are formatted as date in mysql (YYYY-MM-DD)
I diplay the date with a local format by using moment.js.

My issue is that the search is based on mysql value not on rendering.

I cannot use Orthogonal data as it's server side version.

I tested a render function like:

language: { url: "../assets/js/locale/French.json" },
        "columns": [{
                "data": "day",
                "className": "text-right",
                render: function(data, type, full, meta) {
                    if (type == 'display') {
                        if (data) {
                            return moment(data).format("Do/MM/YYYY");
                        }
                    }
                    if (type == 'sort') {
                        if (data) {
                            return data;
                        }
                    }
                    if (type == 'search') {
                        if (data) {
                            return moment(data).format("Do/MM/YYYY");
                        }
                    }
                    return data;
                }
            },....

but it don't work, any solution?

Thanks in advance
raph

Answers

  • raf_mixraf_mix Posts: 12Questions: 3Answers: 0
    edited December 2021

    removed

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    The rendering is done client-side, but the searching is done server-side if serverSide is set, so your server-side scripts would need to either send the data in that rendered format, or apply a similar render when considering the search results,

    Colin

  • raf_mixraf_mix Posts: 12Questions: 3Answers: 0

    Hi, thank for the anser.
    I still tested with "serverSide: false" but in this case I have an empty table.

    raf

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.