Laravel-datatables: Searchable merge columns

Created on 14 Sep 2017  路  3Comments  路  Source: yajra/laravel-datatables

I have this code below but it can only search for last_name.
I want to search for first_name, middle_name, and name_extension also, how can I do that?
Thanks!

{
         `// column definitions`
         `mData: 'last_name',`
         `"aTargets": [ 1 ],`
         `mRender:function ( data, type, row ) {`
             `// concatenate name`                        
             `return row.last_name+' '+row.name_extension+', '+row.first_name+' '+row.middle_name;`
         `},`
         `searchable: true,`
         `sortable: true,`
         `visible: true,`  
},
question

All 3 comments

Try this trick, add a hidden column first_name on your columns and it will be included in search.

columns: [
    {data: 'first_name', visible: false},
    {data: 'last_name'},
]

Thanks for your reply but still can't search for first_name.

It's working! I changed my aoColumnDefs: [] to columns: [] and mData to data and follow the that trick. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t0n1zz picture t0n1zz  路  3Comments

jackrsantana picture jackrsantana  路  3Comments

alejandri picture alejandri  路  3Comments

shadoWalker89 picture shadoWalker89  路  3Comments

sangnguyenplus picture sangnguyenplus  路  3Comments