Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

DataTables - Override Defaults #4910


User avatar
0
blewis created

I am playing around with version 5.3 CORE MVC + jQuery and I have a question concerning customizing a table that is using DataTable. I discovered that ABP has a set of customizations for DataTable located in the datatables.default.js and datatables.ajax.js files. I can follow most of the logic in these files, but I cannot figure out how to override the defaults in the datatable.defaults.js file on a page by page basis. For example, I want to change the default page length from 10 row to 25, but only for certain pages. I see the default of 10 in the defaults.js, but in my page specific js, when I call DataTable, it ignores any attempt to override the default of 10. For example, if I try something like:

var dataTable = _$myPageTable.DataTable({
            paging: true,
            pageLength: 25,
            serverSide: true,
            processing: true,
            listAction: {
                ajaxFunction: _auditLogService.getAuditLogs,
                inputFilter: function () {
                    return createRequestParams();
                }
            }...

I have tried various combinations of possible settings, but I cannot figure this out. What am I missing? I want o do similar overrides for other features, like changing the "entries" in "Showing X to Y entries" to something that's more page specific.

Thanks, Bryan


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    <cite>blewis: </cite> I am playing around with version 5.3 CORE MVC + jQuery and I have a question concerning customizing a table that is using DataTable. I discovered that ABP has a set of customizations for DataTable located in the datatables.default.js and datatables.ajax.js files. I can follow most of the logic in these files, but I cannot figure out how to override the defaults in the datatable.defaults.js file on a page by page basis. For example, I want to change the default page length from 10 row to 25, but only for certain pages. I see the default of 10 in the defaults.js, but in my page specific js, when I call DataTable, it ignores any attempt to override the default of 10.

    You need to import datatables.default.js file to your specific page.