Datatables use with Search Form
Datatables use with Search Form
ad11
Posts: 3Questions: 1Answers: 0
I'd like users to enter data in a form that would be used to generate an ajax url. When the user clicks "Get" on the form, the table would appear with the appropriate data. Don't want the table to appear until the form is submitted the first time. Here are the desired steps:
- Load page, configure table, don't fire AJAX request.
- Enter search parameters
- Submit form.
- Use search parameters to formulate ajax url (i.e. "url": "/people?dept=acct")
- Display table.
- Change search parameters
- Submit form
- Use search parameters to formulate new ajax url (i.e. "url": "/people?dept=eng")
- Display table.
Please let me know an appropriate way to use jQuery to accomplish. Pseudo code is fine. Thanks very much.
This discussion has been closed.
Answers
You might find my yadcf plugin exFilterExternallyTriggered function usefull for your scenario
Here's a solution that seems to work.
Define the table:
var table = $('#table1').DataTable({"columns": [as needed]})
Use DataTable where D is capital
Don't include ajax or data object definition.
Load the data as follows:
table.clear()
table.rows.add( dataToBeAdded )
table.draw()
dataToBeAdded can be obtain through AJAX where the form data is used to query the server.
If you don't want the table to be shown initially. Place the table in a div that is hidden. Unhide the div in step 2.
Comments are very welcome.