pass param to drawcallback after adding a new row that sets the min value for rendering
pass param to drawcallback after adding a new row that sets the min value for rendering
yangyanglouise
Posts: 2Questions: 1Answers: 0
Here is my code for adding a new row. the data from getJSON also returns the min value that i have to set for Qty upon rendering but im not sure how to pass this to drawback. not even sure if drawback is the answer.
function UpdateTableView(e) {
var posUrl = '@Url.Action("UpdateTableView","Invoice")';
var tblCount = pDt.rows().count()+1;
$.getJSON(posUrl, { id: e.id, productTypeId: $('#ProductTypeId').val() }, function (data) {
if (!data) {
return;
}
dtbl.row.add({
"No": data.ArticleNo,
"Description": data.DisplayName,
"Price": data.Price,
"Qty": 1,
"SubTotal": data.Price
}).draw();
});
$('#dgAddProduct').modal('hide');
}//
here is my code for my init. The existing onkeyup function works. Note that it is like a POS type page. how can i render the min value to Qty.
var dtbl = $('#example').DataTable({
paging: false,
searching: false,
info: false,
ordering: false,
language: {
"emptyTable": "No product selected."
},
columns: [
{ data: "No",width:"20%" },
{ data: "Description", width: "40%" },
{ data: "Price", render: $.fn.dataTable.render.number(',', '.', 0, '₱'), width: "15%" },
{
data: "Qty", width: "10%",render: function (data, type, row) {
return '<input class="form-control hello" id="Qty" name="Qty" type="text" value = ' + row.Qty + ' >';
}
},
{ data: "SubTotal", render: $.fn.dataTable.render.number(',', '.', 0, '₱'), width: "15%",className:'dtRight' },
],
"drawCallback": function (settings) {
$(".hello").on('keyup', function () {
var $row = $(this).parents("tr");
var rowData = dtbl.row($row).data();
rowData.Qty = $(this).val();
console.log(rowData.Qty);
});
}
});
This discussion has been closed.