Custom Server Side Parameters

Custom Server Side Parameters

jasper502jasper502 Posts: 25Questions: 9Answers: 0

I am trying to integrate DT with my existing search function - it seems that you can't customize DT to return alternate parameters: i.e. search[value] etc. In my case it would be much easier if I could change that to 'q' for example.

If you can change the default paramater keys returned please advise.

I wanted to try this (https://datatables.net/reference/option/ajax.data):

    ajax: {
      url: $('#locations').data('source'),
      type: 'GET',
      data: {
        q: 'search value'
      }

Where 'search value' is just a clone of the 'search[value]' parameter but I seem to be at a loss how to access this. Can you do it direct from DT or do I need to look it up from the DOM etc?

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921
    Answer ✓

    Here is a server side example of modifying the parameters sent.

    Kevin

  • jasper502jasper502 Posts: 25Questions: 9Answers: 0

    Perfect - that was in the link I provided but had not tried that one yet (was not obvious to me based on my limited JS background). Thanks!

  • jasper502jasper502 Posts: 25Questions: 9Answers: 0

    Follow-up question - is it possible to retrieve the other form data such as length and start? In my case I want to send the length as limit and start as offset.

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921
    Answer ✓

    The d parameter passed into the function has all the parameters. You should be able to use something like d.start. You can use console.log(d) in the function to see the structure.

    Kevin

  • jasper502jasper502 Posts: 25Questions: 9Answers: 0

    Ahhh. Ok that should do the trick ?

This discussion has been closed.