Problem with search field, renderers table fields

Problem with search field, renderers table fields

KumaetsuKumaetsu Posts: 6Questions: 3Answers: 0
edited October 2019 in Free community support

Hello, implement a data table and everything works fine, implement a renderer to concatenate 2 data into a single field of the table, and everything works well, the problem comes is when I try to look for something in the search field returns me the following error , could you help me solve it

frontend:

  { data: null, render: function ( data, type, row ) {
             // Combine the first and last names into a single table field
             return data.autorName+' '+data.autorLastname;
         } },

backend:

$query = App\Informe::query()
    //->join('user_t_o_i_s','user_t_o_i_s.id','informe.userTOI_id');
    ->select([
      'informes.id',
      'informes.clave_IPH',
      'informes.userTOI_id',
      'informes.created_at',
      'informes.typeIPH_id',
      'informes.status',
      'user_t_o_i_s.name as autorName',
      'user_t_o_i_s.first_lastname as autorLastname',
      'type_i_p_h.tipoIPH as tipo'
    ])
    ->leftJoin('user_t_o_i_s', 'informes.userTOI_id', '=', 'user_t_o_i_s.id')
    ->leftJoin('type_i_p_h', 'informes.typeIPH_id', '=', 'type_i_p_h.id');
    return datatables($query)
    ->addColumn('btn','Informes.actionsInformesTOI')
    ->rawColumns(['btn'])
    ->toJson();

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    the search field returns me the following error

    You didn't post the error. Are you also able to link to a page that demonstrates the issue, please.

    Colin

  • KumaetsuKumaetsu Posts: 6Questions: 3Answers: 0

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I don't recognise that PHP API (its not one of ours), so I'm not sure how much I can help, but I would suggest outputting the generated SQL and the bindings so you can see what SQL is being created and what is wrong with it.

    Allan

  • KumaetsuKumaetsu Posts: 6Questions: 3Answers: 0

    I am implementing data table in Larvel, from there comes PHP bakend, what I did was concatenate 2 variables (Name and surname) to be shown together in the table, but that generated the error in the algorithm of "search", tell me if there is any solution or if there is some other way to concatenate information without affecting the "Search" algorithm, thanks

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    I don't know I'm afraid as we didn't write that Laravel backend. You'd be best asking the author of those libraries.

    In DataTables client-side you can use a renderer to combine data. That will probably workaround the issue in this case.

    Allan

This discussion has been closed.