jquery - Cannot get DataTable to load all data -


something seems wrong data, because i'm getting requested unknown parameter 2 row 0 when execute following:

var items = $('#items').datatable({         dom: "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",         paginationtype: "full_numbers",         language: {             lengthmenu: "_menu_ items per page"         },         processing: true,         serverside: true,         statesave: true,         ajax: {             url: "items/data",             method: 'post'         },         columndefs: [             {                 targets: ['th-image'],                 searchable: false,                 data: 'image_url',                 render: function (data, type, full) {                     return '<img src="' + data + '" alt="thumbnail" class="img-thumbnail" />';                 }             },             {                 targets: ['th-manufacturer'],                 data: 'manufacturer',                 render: function (data, type, full) {                     var manufacturer = data.substring(0, 40);                      if (data.length > 40)                         manufacturer += '...';                      return manufacturer;                 }             },             {                 targets: ['th-title'],                 data: 'title',                 render: function (data, type, full) {                     var title = data.substring(0, 40);                      if (data.length > 40)                         title += '...';                      return title;                 }             },             {                 targets: ['th-actions'],                 data: 'actions',                 searchable: false,                 sortable: false             },             {                 targets: ['th-id'],                 data: 'id',                 searchable: true,                 visible: false             }         ]     }); 

on table:

<table class="table table-striped table-bordered" id="items"> <thead>     <tr>         <th class="th-image">image</th>         <th class="th-manufacturer">manufacturer</th>         <th class="th-mpn">mpn</th>         <th class="th-upc">upc</th>         <th class="th-title">title</th>         <th class="th-actions">actions</th>     </tr>     </thead>     <tbody></tbody> </table> 

the fields image, manufacturer, title , actions show correctly, mpn , upc empty despite having values in server data response.

i've created datatables before using same sort of initialization values without need columns value, i'm missing obvious, have yet find it.

datatables 1.10.7.

because you're returning array of objects need define columns data either columns or columndefs options. manual:

the down side of using objects need explicitly tell datatables property should use object each column. done using columns.data , / or columns.render options.

add definitions mpn , upc data properties columndefs shown below resolve problem.

        {             targets: ['th-mpn'],             data: 'mpn'         },         {             targets: ['th-upc'],             data: 'upc'         }, 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -