jquery - createdCell not getting created when .draw() is called after data edit -
i'm using datatables jquery plugin. table renders want when datatable created on page load.
the problem - when update data row (after editing). createdcell have defined in column 2 not getting created upon redrawing table
var sitetable = $('#datagrid').datatable({ ...removed settings not seem relevant problem... columns: [ { data: null, defaultcontent: '', classname: 'select-checkbox', orderable: false }, { data: null, defaultcontent: '', orderable: false, sortable: false, createdcell: function (td, celldata, rowdata, row, col) { $(td).append( $("<button class='btn-edit-row'><i class='glyphicon glyphicon-pencil'></i></button>") ); } }, { data: "site", title: "site", class: "align-center", sortable: true, orderable: true }, { data: "offsetx", title: "offset-x", class: "align-right", sortable: false, orderable: true } ... removed following columns... ] }); // end - $('#datagrid').datatable
here function collect edited row data form , update table data. neither of final 2 lines work expected. table update new data in expected columns createdcell button not populated.
$("body").on("click", "#btnsavedata", function (e) { // row being edited has class var row = $(".editing"); var data = sitetable.row(row).data(); data.site = $("#site").val(); data.offsetx = $("#offsetx").val(); data.offsety = $("#offsety").val(); data.directionname = $("#directionname").val(); data.centeringname = $("#centeringname").val(); data.structurename = $("#structurename").val(); data.source = $("#source").val(); $(row).removeclass("editing") //sitetable.row(row).data(data).draw(); sitetable.row(row).invalidate().draw(); });
Comments
Post a Comment