i have givein column for subjoin coloumn subcategory, when i do sort searching it show ther error

i have givein column for subjoin coloumn subcategory, when i do sort searching it show ther error

guleriamanoj83guleriamanoj83 Posts: 1Questions: 1Answers: 0
edited October 22 in Bug reports

DataTables warning: table id=category-listing - Requested unknown parameter 'child_categories' for row 0, column 2. For more information about this error, please see http://datatables.net/tn/4

$(function() {

    $('#category-listing').DataTable({
      'serverSide':true,
      'processing':true,
      'paging':true,
      'order':[],
      'ajax':{
        'url':'/categories/ajaxIndex',
        'type':'post',
        'dataType': 'json',
        'headers': {
            'X-CSRF-Token': $('meta[name="csrfToken"]').attr('content'),
          },
      },
       "columns": [{ 
      "data": "id",
     },
    { 
      "data": "category",
     },
    { 
      /*"data": "child_categories",
      "name": "subcategory",*/
      "searchable": false, 
    },
    { 
      "data": "markup",
      "name": "markup",
    },
    { 
      "data": "status",
      "name": "Status",
    },
    { 
      "data": "id",
      "name":"action",
      "orderable":false,
    },
  
  ],
    
     "order": [[1, 'asc']],
     /* "columnDefs": [ {
    "targets": [ 0 ],
    "data": "name[, ]"
  } ],  */
      /*'fnCreateRow':function(nRow,aData,iDataIndex){
       // $(nRow).attr('id',aData[0]);
       // $('#category-listing tbody tr:eq('+iDataIndex+')').after($("<tr class='odd'><td colspan='7'> New row here </td></tr>"));


      },*/
       "language": {
        search: ""
      },
     /* 'columnDefs':[{
       "targets": 'no-sort',
          "orderable": false,
      }]*/
      
      "columnDefs": [{
      data: "id",
      'searchable'    : false, 
          render: function (data, type, row, meta) {
               return meta.row + meta.settings._iDisplayStart + 1;
          }
    },{
    "targets": 1,
    "data": "category",
    render: function ( data, type, row, meta ) {
      return data ;
    }
  },{
    
    "targets": 2,
    "data": "child_categories",
    "orderable": false,
    "searchable": false, 
    render: function (value, type, row) {
     if (type === 'display') { 
                        var val = [];
                        $.each(value, function(i, v){
                            val.push(v['category']);
                      })
                      return val;
                   }
    }        

  },{
    "targets": 3,
    "data": "markup",
    "render": function ( data, type, row, meta ) {
      return data ;
    }
  },{
    "targets": 4,
    "data": "status",
    "render": function ( data, type, row, meta ) {
      return data ==  1 ?'<span>Active</span>' :  '<span>Inactive</span>';
    }
  },{
    "targets": 5,
    "data": "id",
    'searchable'    : false, 
    /*"defaultContent": "<a title='Edit' data-toggle='tooltip' class='mx-2' href='/users/edit/'><i class='icon-note menu-icon icon-sm'></i></a><button>delete</button>",*/
    "render": function ( data, type, row, meta ) {
      return '<a title="Edit" data-toggle="tooltip" class="mx-2" href="/categories/edit/'+data+'"><i class="icon-note menu-icon icon-sm"></i></a><a title="Delete" data-toggle="tooltip" class="mx-2 remove-sc"  rel="<?= $this->Url->build(['controller' => 'categories','action' => 'delete']); ?>" data-id="'+data+'" onclick="return confirm(Are you sure ?);"><i class="icon-trash text-danger icon-sm icon-white"></i></a>';
    }

  }  ],
  "fnRowCallback" : function(nRow, aData, iDisplayIndex){
                $("td:first", nRow).html(iDisplayIndex +1);
               return nRow;
            },

    });

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 12,874Questions: 0Answers: 2,198

    Have you followed the steps in the technical notes linked to in the error? That'll be the place to start. If so, what did you find?

    Colin

Sign In or Register to comment.