How can I create a condition in the ajax or controller

How can I create a condition in the ajax or controller

jorgearagon32jorgearagon32 Posts: 1Questions: 1Answers: 0
edited October 2020 in Free community support

my problem is that in a column of a table it comes true or false, and I need that if it comes true it will be shown and if it comes false it will not.

I know this is wrong but so that you can see a clear example of what I want to do.

$('#myTable').DataTable( {
    ajax: ...,

    if(name) {
         columns: [
              { data: 'name' },
              { data: 'hr.position' },
              { data: 'hr.salary' },
              {  data: 'hr.state_date' },
              { data: 'contact.office' },
              { data: 'contact.extn' }
         ]
    }
} );

or in controller

return DataTables::of($did)

      ""   ->where('name', ''=', 'false')   ""
      

->rawColumns(['actions'])
      ->make(true);

Thanks for the help

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

Answers

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

    and I need that if it comes true it will be shown and if it comes false it will not.

    What would you expect to be shown in that column of the table if it is false? It would be worth looking at columns.render as that might get you moving in the right direction,

    Colin

This discussion has been closed.