1.10 - sorting HTML links, case insensitive.

1.10 - sorting HTML links, case insensitive.

beertasticbeertastic Posts: 3Questions: 1Answers: 0

Hi there..
I've just converted my table to ajax enabled. Love it! However, sort by columns is not working correctly.

I'm currently deciding on rendering links in the server before returning, or doing it with JS.

Anyhoo, sorting does not follow any logical process as far as I can tell.

Here's my code:

    $('#listContent').DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": {
            "url": "/dev/admin/ajax/content/",
            "type": "POST"
        },
        columns: [
            { data: 'id'            , 'name': 'content.id' },
            { data: 'title'         , 'name': 'content.title', 'render': function(data, typew, full, meta) { return '<a href="' + DevBaseUrl + '/post/edit/' + full.id + '">' + data + '</a>'; } },
            { data: 'type'          , 'name': 'type' },
            { data: 'parent'        , 'name': 'parent' },
            { data: 'date_start'    , 'name': 'date_start' },
            { data: 'date_expire'   , 'name': 'date_expire' },
            { data: 'status'        , 'name': 'status' },
            { data: 'edit'          , 'name': 'edit' }
        ]
    });

the 'parent' field I'm rendering on the server as a link.. just as an experiment to see which is better.. but nether sorts by the name.. infact, they're all 'random' as far as I can tell.

I read that from V1.10 it should automatically sort by data and not HTML. Is this the case?
How can I tell my sort column to sort by parent data, case insensitive.. and not whatever is happening above?

Cheers!

Answers

  • beertasticbeertastic Posts: 3Questions: 1Answers: 0

    I've just noticed that the title and parent fields... are sorting by id... so it's like the sort happens on column one, regardless of where I click?
    That might be helpful

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    As you are using serverSide processing, your sorting (and searching) should be handled by your own server-side script. With serverSide enabled, DataTables will just present what it's given.

  • beertasticbeertastic Posts: 3Questions: 1Answers: 0

    Makes sense.. However, I don't see anywhere in the docs how to pass that data back to the server. I assumed it was just $_POST vars (I'm using PHP/Laravel 5.3 and https://datatables.yajrabox.com/ plugin FYi...

    There's no docs on how to marry that all up.. I'm still looking though! Cheers for the clarification.

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    I would have pointed you towards DataTables' own server-side docs, but your link has this:

    This package is created to handle server-side works of DataTables jQuery Plugin via AJAX option by using Eloquent ORM, Fluent Query Builder or Collection.

    I don't use Laravel so I wouldn't know where to start with all that, but you may be better off investigating Laravel-based forums.

This discussion has been closed.