Concat datatable field, with serverside search.
Concat datatable field, with serverside search.

Hello
I have some trouble getting CONCAT to work on the my table, while still having the field searchable (server-side-processing).
For the editor I used:
Field::inst( 'hours.project' )
->validator( 'Validate::notEmpty' )
->validator( 'Validate::required' )
->options( Options::inst()
->table( 'projects' )
->value( 'id' )
->label( array('id', 'name') )
),
But when I try to use the render function in the javascript, search starts complaining.
I would like to concat the project id with its name.
Lattest attempt that gives me the expected layout
......
{ data: null,
render: function ( data, type, row ) {
// Combine the first and last names into a single table field
return data.hours.project+' '+data.projects.name;
}
},
.....
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The problem here is that you have
data: null
which means that the server-side doesn't know what the information in the column is (since it could be anything - it is client-side rendered).What you'll need to do for this is to have one column with
data: 'hours.project'
and another hidden column (columns.visible
) withdata: 'projects.name
. You can still use the renderer on the visible column to show them together.Allan
Thanks for the fast reply, but I can't quite get it to work.
I have changed my js to:
the hours.project is a fk-key to the table 'projects'
the json before the change looks like:
Looks like it was another field that was blocking, I will post my javascript when I fix that issue so that others can use it.
have u solve this?