showing 5 rows instead of default 10 rows in datatable, when "pageLength" , "lengthMenu" is not suit

showing 5 rows instead of default 10 rows in datatable, when "pageLength" , "lengthMenu" is not suit

freshcoder00300freshcoder00300 Posts: 2Questions: 2Answers: 0

Usually will showing default 10 datas in a single page, but mine is 14 !?
I want to show 1 to 5 of 14 entries so i tried to put max:5 but it is not working.

the output table still more than 5

var select_server_table = $("#select_server_table_example").DataTable({
    processing: true,
    lengthChange: false,
    serverSide: true,
    pageLength : 5,
    lengthMenu: [[5, 10, 20, -1], [5, 10, 20, 'Todos']],
    ajax: {
        url: "http://192.168.03.30:8000/api/ipc/all",   // fake api
        type: "GET",    
        // dataType : 'json',
        contentType : 'application/json', 
        data: function(d) {
            d.search = d.search.value
            console.log(d)
            return JSON.stringify(d)
        },
        headers: {
            Authorization: "Bearer " + getToken,
        },
        dataSrc: function (response) {
            console.log("DATA", response);
            return response.ipcs;
        }
    },

    columns: [
        { data: "device_id", title: "device_id" },
        { data: "name", title: "name" },
        { data: "group", title: "group" },
    ],

    error:  function(response){
        console.log("ERROR",response);
    }
});

select_server_table.draw();

I tried the discussion discussion , and <table id="table" class="" data-page-length='15' > but not apply to mine, pls take a look

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    edited July 2023

    You have server side processing enabled. It appears your server script doesn't support server side processing. See the Server side processing protocol docs for details.

    What are you using for your server script?

    Maybe consider using the Editor SSP scripts as described in this blog. Or disable server side processing if its not needed. See this doc.

    Kevin

Sign In or Register to comment.