Sorting is not working properly

Sorting is not working properly

Ashish SontakkeAshish Sontakke Posts: 3Questions: 2Answers: 0

While clicking on column for sort arrows are visible on other column as shown in attached files

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    If you don't want other columns to be sorted, disable "orderable" for those columns.
    https://datatables.net/reference/option/columns.orderable

  • Ashish SontakkeAshish Sontakke Posts: 3Questions: 2Answers: 0

    Hi Tangerine,
    I add "orderable" = false to each columns that don't want to sort. please look at code below

    $('#gvClass').DataTable({
    Data:
    $.each(jsonObj, function (i, item) {
    var $tr = $('<tr>').append(
    $('<td>').html("<button type='button' onClick='ClassById(" + item.classid + ")' class='btn btn-link ' id='btnEditClass'><span class='glyphicon glyphicon-edit'></span> Edit</button> "),
    $('<td>').html("<button type='button' onClick='DeleteClass(" + item.classid + ")' class='btn btn-link ' id='btnDeleteClass' style='color:red;'><span class='glyphicon glyphicon-trash' style='color:red;'></span> Delete</button> "),
    $('<td>').text(item.classname)).appendTo('#gvClass');
    }),
    columns: [{ orderable: false, "width": "5%" }, { orderable: false, "width": "5%" }, { orderable: true, "width": "90%" }],
    lengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
    scrollY: '50vh',
    scrollCollapse: true,
    paging: true,
    aaSorting: [[2, 'asc']],
    language: {
    "emptyTable": "Class not available "
    }
    });

  • allanallan Posts: 63,876Questions: 1Answers: 10,529 Site admin
    edited April 2017

    I add "orderable" = false to each columns that don't want to sort.

    Good. And did it work or not? If not, please link to a test case showing the issue.

    Allan

This discussion has been closed.