Search select input wont show records using foreign key database
Search select input wont show records using foreign key database
Link to example case: https://codepen.io/piyush_05/pen/JjGbwZY
Debugger code (debug.datatables.net):
Error messages shown: none
Description of problem: The problem occurs when using select input and server side data processing with a foreign key.
If you choose to select a column that gets its data from another database via foreign key (shows correct options) it will try to search but will say no records found. If you choose a column thats gets its data from the current database it will sort properly. How can I make the input select properly sort the select option?
columns: [{
data: 'event_id', // works
name: 'event_id'
},
{
data: 'eventdata.date', // does not work
name: 'eventdata.date'
},
Answers
Hi,
I'm not entirely clear on how the given example demonstrates what you describe. Could you give me step-by-step instructions on how to see the error?
Thanks,
Allan
See my sceeenshots for examples. On status, event date, city When I try to select and filter by that option it always says "no matching records found"
So it seems to me that this effect is only happening on data being pulled from its foreign key match. Hopefully this brings more clarity. thank you
here is my js
my html
What script are you using for the server-side processing? Whatever that is, is responsible for doing the search. In this case, it sounds like it would need to do a left join to match the value submitted to the text.
What might be better is to have both the foreign key id and the text value from the left join in the data. Then build your
select
with the text value as what the user sees, but the value is the id. Then that is submitted and filtered on in the primary table without needing the look up (and the issues that would arise if two rows had the same text value).Allan