I have integrated Datatable (https://datatables.net) for the listing of records in the Admin Panel. All default functionality (Searching, Sorting) was working fine when I was fetching data/result from single table.
But when I require joining two tables, I am facing below error because of Datatable auto search for every column that you named in your JS code.
Error:
Column not found: - Unknown column
JS code:
{ data: "iBookingId","width": "3%","bSortable":false},(=> From booking)<br>
{ data: "vName","width": "10%","bSortable":false},(=> From users)<br>
{ data: "email","width": "15%","bSortable":false},(=> From users)<br>
{ data: "dDate","width": "7%","bSortable":false},(=> From booking)<br>
How can I resolve that? Any suggestion?
After many efforts, I found the solution.
Simply, you just need to pass new attribute "name" along with data so datatable will search for that column.
{ data: "iBookingId" ,"width": "3%","bSortable":false},
{ data: "vName",name: 'users.vName' ,"width": "10%","bSortable":false},
{ data: "email",name: 'users.email' ,"width": "15%","bSortable":false},
{ data: "dDate" ,"width": "7%","bSortable":false},
PS: Don't apply searchable: false as a patch. :P
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With