Laravel yajra datatable plugin and Datatables 1.9

Laravel yajra datatable plugin and Datatables 1.9

fabioifabioi Posts: 4Questions: 2Answers: 0

Hi, we recently switch from to yajra datatables from Bllim\Datatables\Datatables.
We are using datatables 1.9. Since the switch however pagination is not working.

The generated Json is like this:

recordsTotal: 191,
recordsFiltered: 191,

Any hint of what could be the problem?

Thanks in advance

Answers

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

    I have no idea what "yajra" is. Does it support DataTables 1.9?

  • fabioifabioi Posts: 4Questions: 2Answers: 0
    edited September 2015

    Hi thanks for you reply!
    yajra is Laravel datatable plugin for server side processing.

    I did some more testing, we are using datatables 1.9.
    The error now I get is:
    Column not found: 1054 Unknown column '' in 'order clause'.

    We are using the code below to initiate the datatable. Any idea/hint of what could be the problem?


    // Initialise main table - Customers var oTable = $('#' + tableID).dataTable({ "bAutoWidth": false, "sDom": "r<'row'<'col-md-6 actionBtnBox'l><'col-md-6 filterbutton'Cf>>t<'row'<'col-md-6'i><'col-md-6'p>>", "colVis": { "exclude": [0, 1, 2, 11], "buttonText": '<i title="Show/hide columns" class="fa fa-columns"></i>', "align": "right", "overlayFade": 250 }, "bStateSave": saveState, "serverSide": true, "processing": true, "serverMethod": "POST", "ajaxSource": "<source..>", "aaSorting": [[6, "desc"]], "bSort": true, "aoColumns": [ { "bSortable": false, "bSearchable": false, "mDataProp": "checkbox" }, { "bSortable": false, "bSearchable": false, "mDataProp": "drilldown", "sClass": "control" }, { "bVisible": false, "bSearchable": false, "mDataProp": "slug" }, { "mDataProp": "column_1", }, {"mDataProp": "review_id"}, {"mDataProp": "column_3"}, { //"sType": "date-euro", "mDataProp": "column_4" }, { "sType": "html", "mDataProp": "column_5" }, {"mDataProp": "column_6"}, { "sType": "html", "mDataProp": "column_7" }, { //"sType": "date-euro", "mDataProp": "column_8" }, { "bVisible": false, "sType": "numeric", "mDataProp": "column_9" }, { "iDataSort": 11, "bSearchable": false, "mDataProp": "time_worked" }, { "sType": "html", "bSearchable": false, "mDataProp": "risk" } ], "fnDrawCallback": function (oSettings) { // On redrawing the table reset the opacity for all rows. $('tbody tr').css('opacity', fadedInOpacity); // Check if there are opened subtables if ($(".subtableopened").length > 0) { // Change the opacity for all other rows to the faded-out setting $('#' + tableID + ' > tbody > tr').not(".subtableopened").fadeTo('slow', fadedOutOpacity); } }, "fnInitComplete": function (oSettings, json) { //$("#gridLoading").addClass('hide'); }, "language": { "processing": '<img src="/template/images/loader.gif"> Loading results...' }
  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin
    edited September 2015

    The issue is that the new package you are using supports DataTables 1.10+, not 1.9 which is a legacy version and no longer supported. Unless the new package has a legacy mode, you would need to modify it to work with the legacy options or update to 1.10+. See also the server-side processing manual.

    Allan

    p.s. yajra is a popular Laravel package for DataTables. it is third party and not supported in these forums.

  • fabioifabioi Posts: 4Questions: 2Answers: 0

    Hi Allan,

    thanks but for what I read in the Laravel Plugin github page they seems to support 1.9,
    https://github.com/yajra/laravel-datatables
    "Works with DataTables v1.9 and v1.10 legacy code."

    So I am maybe not properly initializating the datatables from the JS side?
    Fabio

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    "serverSide": true,

    That is a 1.10+ parameter. See the legacy documentation for the old style parameters.

    Allan

This discussion has been closed.