Script.js
пример кода для связывания с данными jquery.
var oTable = $("#tblProduct").DataTable({
"serverSide": true,
"sAjaxSource": "/Product/GetProductList",
"filter": false,
"orderMulti": false,
"responsive": true,
"iDisplayLength": 10,
"iDisplayStart": 0,
"language": {
"url": LanguageUrl,
},
//send server parameter
"fnServerParams": function (aoData) {
aoData.push({ "name": "ProductCode", "value": $("#ProductCode").val() });
aoData.push({ "name": "ProductDescription", "value": $("#ProductDescription").val() });
},
"aaSorting": [[0, "asc"]],
"columns": [
{ "data": "ProductDimension", "orderable": false, },
{ "data": "ProductCategory", "orderable": true, },
{ "data": "CurrentStock", "orderable": true, },
{ "data": "InOrder", "orderable": true, },
{ "data": "Planned", "orderable": true, },
{ "data": "Required", "orderable": false },
{ "data": "WeightPerPiece", "orderable": true },
{
"data": "Archived", "orderable": false,
"render": function (data, type, row) {
return row.Archived == false ? "Active" : "Inactive";
}
}
],
});
вот код .cshtml
<table id="tblProduct" class="table table-bordered table-striped" width="100%">
<thead>
<tr>
<th width="20%">@_Localizer["Product Code"]</th>
<th width="24%">@_Localizer["Description"]</th>
<th width="11%">@_Localizer["Product Dimension"]</th>
<th width="11%">@_Localizer["Product Category"]</th>
<th width="5%">@_Localizer["Stock"]</th>
<th width="7%">@_Localizer["In Order"]</th>
<th width="5%">@_Localizer["Planned"]</th>
</tr>
</thead>
</table>
Я надеюсь, что это работает для вас