Rendering one table based on row selected in another

Rendering one table based on row selected in another

medusa101medusa101 Posts: 10Questions: 0Answers: 0

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

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    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 call draw() on the second table whenever you want to update it (presumably on a row selection change in the first).

    Allan

  • medusa101medusa101 Posts: 10Questions: 0Answers: 0

    Interesting Allan. It always surprises me how many things you have thought of. Its design is fantastic.

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Thanks :-)

    Allan

  • medusa101medusa101 Posts: 10Questions: 0Answers: 0

    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.

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    What I suspect you will need to do is use ajax.data to send in the admission ID, and then use the PHP Editor's where() method (assuming you are using the PHP libraries) to add a WHERE condition to the table for that admission ID. Then call ajax.reload() to reload the table with the new admission ID.

    Allan

  • medusa101medusa101 Posts: 10Questions: 0Answers: 0

    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?

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    I should have linked to it - sorry. It is available here.

    Allan

  • medusa101medusa101 Posts: 10Questions: 0Answers: 0

    Allan,

    Thanks. After reading the documentation, I am even more confused. Do I call it before process() or after process() on the Editor instance.

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Before. The process() method will apply the configuration that has been set up already. Applying where() after process() would have no effect, since everything has already been processed!

    Allan

This discussion has been closed.