admin管理员组文章数量:1296505
I have a code that I am trying to understand, from another developer. He is using datatable.js, something like:
function initservicesDataTable(){
DataTable.datetime('DD/MM/YYYY');
let config = {
order: [[3, 'asc']],
columns: [
{ orderable: false, width: '10%' }
// more columns
],
fixedColumns: {
left: 1,
},
fixedHeader: {
header: false,
footer: true
},
initComplete: function () {
// add embedded filters
this.api()
.columns()
.every(function () {
let column = this;
let title = column.footer().textContent;
// More code
});
}
};
return new DataTable('.dt-services', $.extend({}, config, GetDatatableConfig()));
}
He then has an action (Index) inside the Home Controller where he fills up the model and use to create the table:
public IActionResult Index()
{ // call all the data from the context, as of View(Model). No pagination applied }
The View is as below:
<div class="datatable table-responsive shadow-sm mt-3 mb-3">
<table class="table table-striped table-hover dt-services">
<thead>
<tr>
<th scope="col" class="text-center">Name</th>
</tr>
</thead>
<tbody>
@foreach (Service service in Model)
{
<tr>
<td class="dt-left">
@service.Name
</td>
</tr>
}
</tbody>
<tfoot>
<tr>
<th>Name</th>
</tr>
</tfoot>
</table>
</div>
I have been trying to apply pagination, but I could not, in the index nothing is paginated, all the data is returned, and I cannot paginate, could anyone shed a light on how I could applomplish this? I tried multiple exampled and none worked.
本文标签: javascriptPagination with Datatablejs and aspnet mvcStack Overflow
版权声明:本文标题:javascript - Pagination with Datatable.js and aspnet mvc - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741631839a2389410.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论