length and start parameters in server side request

length and start parameters in server side request

mandetemandete Posts: 3Questions: 1Answers: 0
edited December 2015 in Free community support

Hi, i'm trying to make a server side request with start and length paramets (i will only want to show the 3 first registers), but it doesn't work!.

I've tried with this two options:

option 1:

var table = $('#tablas').DataTable({
    "ajax" :{
        "url":  "/include/scripts/script.php",
    "start": 0,
    "length": 3
    },
    "serverSide": true,
...

option 2:

var table = $('#tablas').DataTable({
    "ajax" : "/include/scripts/script.php",
     "start": 0,
     "length": 3
     "serverSide": true,
...

What can i do??

Thanks!!

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    Start and Length are sent by dataTables in the GET or POST to your ajax URL.

    You configure with pageLength.

    "ajax" :{
            "url":  "/include/scripts/script.php",
        },
        "serverSide": true,
      , lengthMenu:[[3,25,50,100,-1],[3,25,50,100,"All"]]
      , "pageLength":3
      , pagingType: "full_numbers"
    
  • mandetemandete Posts: 3Questions: 1Answers: 0

    But i don't want paginate in this datatables, i only want receive the 3 first records and thats all. But i don't want to make this directly in the sql query because in other page i want the same query but receiving all the records.

  • mandetemandete Posts: 3Questions: 1Answers: 0

    Finally i make a normal server side request with paginate, limiting to 3 records by page and hidden via dom the paginate. In this way i can show only three first records and anything else ;)

  • allanallan Posts: 63,353Questions: 1Answers: 10,444 Site admin

    Use ajax.data if you want to send additional data to the server.

    Allan

This discussion has been closed.