jamesdordoy / laravel-vue-datatable

Vue.js Datatable made for Laravel
https://jamesdordoy.github.io/laravel-vue-datatable
MIT License
151 stars 52 forks source link

Concat two columns data #160

Closed redleon00 closed 1 year ago

redleon00 commented 1 year ago

Hi, i'm using laravel-vue-datatable but i don't know how i can concat two columns from the data, how i can do it?

jamesdordoy commented 1 year ago

Hey @redleon00,

from memory, you can do that using the transform property when defining a column https://github.com/jamesdordoy/laravel-vue-datatable#column-props

e.g.

{
 name: 'first_name',
 label: 'Full Name',
 transform: (row) => { return row.first_name + ' ' + row.last_name }
}

Shout if that dosnt work but think it should

redleon00 commented 1 year ago

Thx u @jamesdordoy for your response, ok i this moment i resolve ir using a map function with the data but i will try your solution.

redleon00 commented 1 year ago

transform: ({data}) => { return data.owner.name + ' ' + data.owner.last_name }

That is the solution, only have to change row for data and the braquets, thx u @jamesdordoy