Foreign key MySQL queries referencing more than one DB table

Foreign key MySQL queries referencing more than one DB table

aCoradatatblaCoradatatbl Posts: 16Questions: 7Answers: 0
edited October 2015 in Free community support

Hi,
I have implemented my own server-side script for handling population of data from MySQL. Using the included example file (for db field mapping to dt column names and the datatable is being written correctly. The problem is that the column-filtering on one of the columns (containing the result of a foreign-key query) is now broken and produces No-Matches! when there should be.

I can see its trying to match the foreign-key (int) against the text in the column since the column mapping dictates this, but how can i bring the second db table into the mapping of db -> dt columns?? so the filtering is done properly?

Please see these screenshots :

Environment:

  • PHP 5.3
  • jquery-1.11.1.min.js
  • jquery_ui/jquery-ui.min.js
  • DataTables 1.10.4
  • Google Chrome Version 45.0.2454.101 m

With thanks in advance ...

Answers

  • allanallan Posts: 63,124Questions: 1Answers: 10,397 Site admin

    DataTables sends the column data property to the server using columns[].data (see the manual) so you could perhaps use that to reverse map from the column data property (active in this case) to whatever table / field it needs to refer to.

    Allan

  • aCoradatatblaCoradatatbl Posts: 16Questions: 7Answers: 0
    edited October 2015

    hi, allan,
    Cheers for the info - not sure what that means though, where would i add such a mapping so that it only affects filtering on that column. It would be good if my custom foreign-key function used during initialisation of that column could be called each time for that column filtering.

    Any ideas??

  • allanallan Posts: 63,124Questions: 1Answers: 10,397 Site admin

    I was sort of guessing on the information above, and it looks like I guess wrong on how your code is working :-).

    What you probably need to do in that case (having reread your description) is have the text value converted to the integer value for that column (I'm assuming that integer filtering works, ir just isn't useful for the end user)? If so, you'd just need to confirm the user's input value into the required integer.

    Allan

This discussion has been closed.