Auto Refresh on Dropdown

Auto Refresh on Dropdown

kashifaukashifau Posts: 9Questions: 2Answers: 0

I am using CakePHP. I added a dropdown to my template (https://datatables.net/forums/uploads/editor/rg/xfgh8ofwyfvz.png) and when I select any option some sort of event, perhaps an ajax call is automatically called. Is there a way to stop that or detect what event is being called so I can add logic to it?

Replies

  • kashifaukashifau Posts: 9Questions: 2Answers: 0

    Photo missing in previous post:

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

    That dropdown isn't part of the DataTable, it's a control created in your code, so that means it's going to be something in your code or CakePHP that's generating the event. It might be worth asking on StackOverflow or a forum dedicated to CakePHP,

    Colin

  • kashifaukashifau Posts: 9Questions: 2Answers: 0

    I also thought so but when I use var table = $('#Events').DataTable(); inside a script tag on that page, the auto refresh stops. Is there a way to disable datatables ajax on a particular page?

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

    You can reset the URL to an empty string in ajax.url(), that would stop it being able to get any more data.

    Colin

  • kashifaukashifau Posts: 9Questions: 2Answers: 0

    Thanks will try that. There is another related issue on the same page. I am using drop down to filter data and it successfully returns the desired result when I click filter button, but when I click any of the page number the paging is reset to original query and the filtering is lost. I found this link https://datatables.net/reference/api/ajax.reload() but it didn't work.

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

    We would need to see that to understand the flow. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kashifaukashifau Posts: 9Questions: 2Answers: 0

    I solved the issue using session variables, but would be keen to find another more datatables oriented approach.

Sign In or Register to comment.