Refreshing the data after changing dropdown
Refreshing the data after changing dropdown
I am using the example code at https://editor.datatables.net/examples/inline-editing/tabControl.html
I want to add a form element outside the table where I select a value that needs to be passed to the query to select the data.
How might I go about it?
Regards
Pete
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You could use
ajax.data
as a function to modify the data object Editor sends to the server. If you want to modify the data object DataTables sends (when loading the data) useajax.data
.Allan
OK, thanks for this, I want to initialise the dropdown with data based on the user profile, so they see data related to themselves, not everything. But certain users can select a different set of data so the table will need to be refreshed, after it has been initialised with the first set of data and may have been updated.
It's how I refresh the data that I am not sure of.
Pete
Is this in a
select
list? If so, look at theupdate()
method for theselect
field type - it provides the option to update the options available in the list.Allan
Alan,
It's outside the table. Basically I want to capture staff hours, some managers can work across more than one branch, they can change the branch dropdown and a weekending date dropdown too.
These values need to be passed to the query initially based on their logon profile or if they change the dropdowns.
Pete
Hi Pete,
To pass additional information to the server on the initial data get request that DataTables makes, use
ajax.data
as a function. Then when you refresh the data in the table (which you would do usingajax.reload()
- assuming you are usingajax
to load the data) that function will be re-evaluated and the extra data sent to the server.Example here. You might read the additional information using a little jQuery -
d.myVar = $('#myInput').val();
for example.Regards,
Allan
I'm not sure that I can pass the selected data across to a where clause in the PHP.
Maybe I will have to write my ASP version.
Pete
I'm a little confused as to where the data is passed to/from. I'm using the Editor extension and so if I want to pass this extra data is it the same for Editor as it is for Datatables?
Regards
Pete
Hi Pete,
DataTables and Editor each use their own Ajax configuration object. They basically provide the same options (with a few small variances which are noted in the documentation).
The option to manipulate the data object sent to the server are the ones I linked to in my first post above:
ajax.data
ajax.data
Allan