linked tables

linked tables

makismakis Posts: 1Questions: 0Answers: 0
edited September 2010 in General
Hello,

I have two tables with two headers each. The first is common between the two. So, the two tables could be
table 1 table 2
Name Address Name Phone No.
.. .. .. ..

What i want to do is when i sort the Address column in table 1, the Name column in table 2 to automatically sort as the Name column in table 1.

Is there a way for that?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    There certainly is. In fact there are probably a number of ways of doing it... The easiest I would imagine would be to use fnDrawCallback ( http://datatables.net/usage/callbacks#fnDrawCallback ). In there you could look for the sorting conditions you want ( oSettings.aaSorting ) and then apply the required sort to the second table using fnSort ( http://datatables.net/api#fnSort ).

    So it will require a little bit of logic in the callback function - but yes this is possible.

    Regards,
    Allan
  • ruzzruzz Posts: 49Questions: 0Answers: 0
    Just a thought...

    As the saying goes, there's always more than one way to skin a cat... but first make sure it's a cat, not a dog. It strikes me the best solution is to solve this at the backend using a join/view merging the two tables' rows so that on the client, there's only one table.

    Of course, if there isn't a 1 to 1 relation between the rows, or worse, you don't have access/control over the server output this is unlikely to work. But the way the example was given, it looks to be possible.

    ruzz
This discussion has been closed.