Rendering one table based on row selected in another
Rendering one table based on row selected in another
Hi,
I want to be able to render Datatable 2 based on a row selected in Datatable 1.
For example - the key in table 1 is Admission ID. When I select a specific Admission ID in table 1, I want to be able to show (an add) Payments associated with that Admission ID in Datatable2. I also want to be able to add new payments to the same admission ID.
I suspect I will have to call the redraw method with changed URL sending the admission ID in PHP URL for data table 2 to pick up the rows. However, the server side processing in this case is a little confusing to me.
Replies
Sounds perfectly possible. If you are using server-side processing, then use
ajax.data
as a function in the second table to add the required data to sent to the server based on the selected rows, and then simply calldraw()
on the second table whenever you want to update it (presumably on a row selection change in the first).Allan
Interesting Allan. It always surprises me how many things you have thought of. Its design is fantastic.
Thanks :-)
Allan
Allan,
Sorry for bugging you. I got the concept. What I do not get is how is the data processed in PHP. I can see for stand usage we simply process all the data coming in _POST based on the definition. What is the PHP processing that can be done based on the mechanism you have described above? How do I use the static data sent - in this case - admission ID.
What I suspect you will need to do is use
ajax.data
to send in the admission ID, and then use the PHP Editor'swhere()
method (assuming you are using the PHP libraries) to add aWHERE
condition to the table for that admission ID. Then callajax.reload()
to reload the table with the new admission ID.Allan
Hi Allan,
I could not find the documentation for where() method on the site. Do I need to need to generate documentation from Editor PHP libraries provided?
I should have linked to it - sorry. It is available here.
Allan
Allan,
Thanks. After reading the documentation, I am even more confused. Do I call it before process() or after process() on the Editor instance.
Before. The
process()
method will apply the configuration that has been set up already. Applyingwhere()
afterprocess()
would have no effect, since everything has already been processed!Allan