I have similar case to a question bellow
I have a jQuery datatable and every thing is going alright from binding on the server side to showing data, but I need to submit the datatable from my razor page to another controller. So, I need the checked rows and non checked rows as well with their ids, so when I submit to controller all data in datatable are submitted well except the checkboxes values are not being updated ,they have been sent with their initial values ,even if I checked or unchecked them , I got only the initial value they got from the server on first bind
@section scripts {
<script>
var obj = @Html.Raw(Json.Serialize(Model));
var storeId = document.getElementById('idStore').value;
var tableParam;
$(document).ready(function () {
$('#myTable').DataTable({
"proccessing": true,
"serverSide": true,
"ajax": {
url: "/item/loaddata",
type: 'POST',
headers: { 'RequestVerificationToken': $('@Html.AntiForgeryToken()').val() },
data: { "StoreId": storeId }
},
"columnDefs": [
{
"targets": 0,
"checkboxes": {
"selectRow": true
},
}
],
"select": {
"style": "multi"
},
"columns": [
{
"data": "selected", "searchable": false, "render": function (data, type, row) {
return '<input type="checkbox" class="chk"' + (data ? ' checked' : '') + '/>';
}
},
{"name":"SNumber", "data": "tname"},
{ "name": "MName", "data": "lname" },
{ "name": "SGuid", "data": "itemguid", "visible": false, "searchable": false },
],
"order": [[0, "desc"]]
});
});
</script>
<script type="text/javascript">
$(document).on("click", "#btnSave", function (e) {
var table = $('#myTable').DataTable();
var datac = table.rows(function (idx, data, node) {
return $(node);
}).data().toArray();
$.ajax({
url: "/inventory/saveselecteditems",
type: 'post'
, data: { "testmodel": datac }
});
});
</script>
}