Javascript Method Custom Sort

Javascript Method Custom Sort

jamessteelforthjamessteelforth Posts: 17Questions: 4Answers: 0

Hi Alan,

I have been trying to disable standard sorting on the datatable using :

$('#example th').unbind('click.sorting'); OR $('#example thead').unbind('click.sorting');

The sort does not get disabled. The following is my initialisation code

                    $('#example').dataTable({
            "processing":true,
        "scrollX": true,
        "scrollY": "300px",
        "scrollCollapse": true,
        "paginate": false,
            "dom": "C<'clear'>lrtip",
            "colVis": {
                    "exclude": [0,1],
                    "showAll": "Show all",
                    "align":"left"
                  },
        "columns": 
        [   
            { "title": "Row ID", "visible" : false },
            { "title": "<button onclick = 'DeleteButtonClick()'>Delete<br/>Selected</button>", "orderable":false},
            { "title": "Effective Date"},
            { "title": "Item Number" },
                    ]

Secondly i want to be able to call a custom JavaScript method on click of the header, something like function ApplySort(some Column identifier).

Its in ApplySort() function that i'll call the external web service which has like 101 constraints to the way one calls it. So i would like the JavaScript function to be able to recognize the column header on which click has happened and i'll take it forward from there.

How do i do this??

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    unbind('click.sorting');

    DataTables doesn't use the name space sorting (is that in the documentation somewhere?). Just unbind the click event without a namespace.

    Secondly i want to be able to call a custom JavaScript method on click of the header, something like function ApplySort(some Column identifier).

    Hmmm - I don't think there is a way to do that directly. You can write a custom sort method which DataTables will call itself internally when needed, but there is no way to have an external source sorting the data and redrawing the table.

    Allan

This discussion has been closed.