Mjoin alias - Select lists not filtering on WHERE clause
Mjoin alias - Select lists not filtering on WHERE clause
This question relates to a previous question at https://datatables.net/forums/discussion/65165/mjoin-alias-and-displaying-results#latest
I have 7 Mjoins which use alias names and have WHERE clauses.
The records from those Mjoins display fine in datatables, and are correctly filtered according to the WHERE clauses in those Mjoins.
There are 7 selects in the editor which are each populated by those Mjoins. However, those selects are not being filtered by the WHERE clauses, as all have identical options in the select, i.e. all records without filtering.
Any ideas? See code in the following comments.
This question has an accepted answers - jump to answer
Answers
HTML:
Datatables example:
Editor select list example:
Server side code in
unit_outcome_data.php
:And some images:
Selects with the same options:
https://paste.pics/1a045ad6e3c8ac7c4b18f9662a36e123
Records in Datatables showing the discipline_outcomes correctly filtered on the WHERE clauses from the 7 Mjoins:
https://paste.pics/479117198b9e1cfe139c31e4df8c9c27
And the JSON with queries:
https://www.dropbox.com/s/jpm3uyxwsq4dg2m/json.txt?dl=0
And the relevant tables and data in dbfiddle:
https://www.db-fiddle.com/f/7B8pRJKmyX321khhzydeBN/0
OK, got it working with:
Spoke to soon again... When updating I get:
I noticed that the unit_outcome name, while showing in datatables, is not showing in the editor field when editing. Not sure though if this is related to the above error.
The issue appears to be just with editing, creating a new record works OK...
Hi,
Sorry for the delay in replying in your other thread on this topic, I've done so now, but I see you are ahead of that already having found the
where()
method for the Mjoin.What version of the libraries are you using? On line 974 (Editor.php) in the 1.9.5 release, there isn't a
foreach
.Thanks,
Allan
Hi Allan
I was using 1.9.0. I have now updated to the latest version 1.9.5.
Still getting a system error has occurred (More information).
The error is:
The error still occurs only on update/edit, no problems creating a new record.
The unit_outcome name I note is missing on the editor model. The field is there, but it is empty. See https://paste.pics/77e88c2bfb6d5e884ff69dde67e12271
You can see in the image in that link that the unit_outcome name field is empty. You can also see just above the modal the record being edited (with the red expander) which shows the unit_outcome name. I don't know if that is a result of the error.
OK, the error only happens using the inline edit button, not the main edit button at the top of the page. Also, using the main edit button, the unit_outcome name field is populated OK - it was empty using the inline edit button.
Well, it appears that the issue only occurs when using the inline edit button AND the responsive kicks in with the ability to expand to see the inline edit button.
With all columns visible (e.g. on a wide monitor) and no responsive needed to see the inline edit button, then inline edit works fine, no error.
BTW, re 'inline' edit, I mean having an edit button on the final column of each row...
Do you mean like what is shown in this example?
I think I'd need to be able to see a running example showing the error in this case if you can give me a link to the page?
Allan
Sort of. That link you provided has responsive, but no edit button/link on the last column. It is that Edit button/link that when shown by responsive, causes the update error. On a naturally expanded page, without requiring responsive to show that Edit button in the last column, that Edit button/link in the last column works fine.
I have sent to you a message re access.
Peter
Ah! I see what you mean now - thanks.
The issue is here:
More specifically the
$( this ).closest( 'tr' )
. That is not selecting the row you want to edit when your click is in the child row.What you can do however, is pass in the row to the DataTable row selector which will return the row required:
And then pass
row
into theeditor.edit( row, .... )
call.Allan
Thanks Allan.
Using:
the alert shows undefined and the editor fields show "multiple values".
Sorry yes - that was a mistake (I was thinking of an implementation that hasn't been deployed yet). You need to determine if your link element is in the child row or not:
Thanks,
Allan
Thanks Allan that works fine.
Peter