mercredi 27 mars 2019

Cannot read property 'rows' of undefined

Getting Cannot read property 'rows' of undefined even after I have set the id to the table row

I have read through the questions posted related to this error but still could'nt solve my problem

Uncaught TypeError: Cannot read property 'rows' of undefined phonegap

Cannot read property 'row' of undefined

https://datatables.net/reference/option/rowId

$('#deliverytable').on( 'click', 'tr', function () {
var deliveryid = deliverytable.row( this ).data().deliveryform.Id;
});
console.log(deliveryid)

The console.log returns "undefined"

This is the table

deliverytable=$('#deliverytable').DataTable( {
 columnDefs: [{ "visible": false, "targets" :[1,2,3]},{"className": "dt-center", "targets": "_all"}],
          responsive: false,
          colReorder: false,
          dom: "Blftp",
          sScrollX: "100%",
          bAutoWidth: true,
          sScrollY: "100%",
          rowId:"deliveryform.Id",
          scrollCollapse: true,
          //The error comes from here
          fnInitComplete: function(oSettings, json) {
          $('#mypendingdeliverytab').html("My Pending Delivery" + "[" + 
          deliverytable.rows().count() +"]")

                                  },
columns: [
         { data: null, "render":"", title:"No"},
         { data: "deliveryform.Id"},
         { data: "deliverystatuses.Id"},
         { data: "requestor.Name", title:"Requestor"},
         { data: "roadtax.Vehicle_No",title:"Vehicle No"},
         { data: "roadtax.Lorry_Size",title:"Size"},
         { data: "driver.Name",title:"Driver"},
         { data: "deliveryform.delivery_date",title:"Date"},
         { data: "radius.Location_Name",title:"Site"},
         { data: "projects.Project_Name", title:"Project Name"},
         { data: "options.Option", title:"Purpose"},
         { data: "deliveryform.PIC_Name", title:"PIC Name"},
         { data: "deliveryform.PIC_Contact", title:"PIC Contact"},
         { data: "deliveryform.Remarks", title:"Remarks"},
         ],
         select: {
                   style:    'os',
                   selector: 'tr'
                  },

         buttons:[],
});

The error comes out whenever I try to retrieve the row id. From the row that I have commented // on I received this Cannot read property 'rows' of undefined



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire