jquery - Add row in datatable is working but edit a row or inline edit not working -


i using datatable , add dynamic row it's working want edit row not working editing code.

var t= $('#example').datatable({           //dom: "bfrtip",         //ajax: "../php/staff.php",         'fncreatedrow': function (nrow, adata, idataindex) {         $(nrow).attr('id', 'row_' + adata[0]); // or whatever choose set id         }  $('#add_company').click(function(e){     if(result)     {          t.row.add( [             counter,             $("#payment_company ").val(),             $("#payment_date").val(),             $("#payment_type").val(),             $("#payment_amount").val()          ] ).draw( true );      //$('#amount_form').trigger("reset");         counter++;     } 

editing code below

editor = new $.fn.datatable.editor( {         //ajax: "../php/staff.php",         table: "#example"     } );  $('#example').on( 'click', 'tbody td:not()', function (e) {         editor.inline( );     } ); 

use code

var t= $('#example').datatable({           //dom: "bfrtip",         //ajax: "../php/staff.php",         /*'fncreatedrow': function (nrow, adata, idataindex) {         $(nrow).attr('id', 'row_' +idataindex); // or whatever choose set id         },*/          columns: [             { data: "s_no" },             { data: "payment_company" },             { data: "payment_date" },             { data: "payment_type" },             { data: "payment_amount"}         ]     });  $('#add_company').click(function(e){     if(result)     {         t.rows.add( [{ "dt_rowid": "row_"+counter,                      "s_no":counter,         "payment_company":  $("#payment_company ").val(),         "payment_date":   $("#payment_date").val(),         "payment_type":  $("#payment_type").val(),         "payment_amount":$("#payment_amount").val() }      ] ).draw(false);      //$('#amount_form').trigger("reset");         counter++;     } 

and change inline edit code

  editor = new $.fn.datatable.editor( {         //ajax: "../php/staff.php",         table: "#example",        fields: [ {                 label: "s.no:",                 name: "s_no"             }, {                 label: "payment company:",                 name: "payment_company"             }, {                 label: "payment date:",                 name: "payment_date"             }, {                 label: "payment type:",                 name: "payment_type"             }, {                 label: "payment amount:",                 name: "payment_amount"             }         ]     } );     // activate inline edit on click of table cell     $('#example').on( 'click', 'tbody td:not()', function (e) {         editor.inline( );     } ); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -