start paramater pass to the server on get post request

start paramater pass to the server on get post request

frenchmakerfrenchmaker Posts: 11Questions: 1Answers: 1

Hi,
Each time i press the button to order a column the start parameter reset to 0 and also get my pagination back to the page 1

For exemple i change page and my start point change 0 to 10 to 20 to 30 etc...
but when i press the button to order a column the start point send to 0

is there a way to add a property to the object to say each time the order button is press to not reset the start point to 0?

i hope you understand

ps: sorry for my bad english

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @frenchmaker ,

    You could do something like this - this is resetting the page in the order back to where it was.

    If you've got serverSide enabled, you could try adding an additional parameter with ajax.data that sends the old page number.

    Cheers,

    Colin

  • frenchmakerfrenchmaker Posts: 11Questions: 1Answers: 1
    edited November 2018

    @colin
    For the paging your code is working but datatables keep sending start parameter to 0 and resulting my server query to send the first 10 data to datatable to the actual paging. Exemple i go on page 3 and click to order a column my server is sending first 10. well here some code to visualize.

    my backend is express and im using mongodb with mongoose and i use the
    {'skip': Number(start), 'limit': Number(length)} object options to skip an given start point that come with the datatable request and length where to stop querying. and for counting document im also using
    await Disk.countDocuments({}, async (err, c) => {
    recordsTotal=c;
    await Disk.countDocuments(query, async (err, c) => {
    recordsFiltered=c;
    the query is simply a regular expression logic for the search input.

    but, all i want is when i press the order button i want datatable to actually send the start parameter and dont reset it to 0.

    i was about to use carbon.sh to share code but the upload dont work and there no actually sharing code website for express and angular app

  • frenchmakerfrenchmaker Posts: 11Questions: 1Answers: 1

    here my ajax
    'ajax': {
    beforeSend: function (request) {
    request.setRequestHeader('Authorization', 'Bearer' + authToken);
    },
    url: 'http://localhost:3000/api/dashboard/getalldisks',
    dataType: 'json',
    type: 'POST',
    data: function(d) {
    d.param = getNavigationParameterJS();
    console.log(d.start);
    }
    },

  • frenchmakerfrenchmaker Posts: 11Questions: 1Answers: 1
    edited November 2018

    here the request ;
    {draw: 3, columns: Array(11), order: Array(1), start: 0, length: 10, …}
    columns: (11) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
    draw: 3
    length: 10
    order: [{…}]
    param: "vueglobale"
    search: {value: "", regex: true}
    start: 0
    proto: Object

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @frenchmaker ,

    This example here is using serverSide and is updating the Ajax request to maintain the page position.

    Hope that does the trick!

    Cheers,

    Colin

  • frenchmakerfrenchmaker Posts: 11Questions: 1Answers: 1

    Yes that work perfectly thank you

This discussion has been closed.