Datatable list of visible columns on server side from stateSave

Datatable list of visible columns on server side from stateSave

karmendrakarmendra Posts: 13Questions: 5Answers: 0

I want to get the list visible columns from the front-end when a page with dataTables is loaded.
This will help me decide what query to run to fetch only those columns.

First time user sees the page, he will see the data with default columns, but if he chooses to not show certain columns this information gets saved in stateSave, next time he visits the page I should get the information about what are the visible columns and I update run different query to fetch only those visible columns.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 9,518Questions: 0Answers: 1,576

    Hi @karmendra ,

    colums().visible() can be used to get the visible status of the columns,

    Cheers,

    Colin

  • karmendrakarmendra Posts: 13Questions: 5Answers: 0

    I need this information colums().visible() on server side when the ajax request get/post is called to fetch data.

    I use Yajra Laravel datatables plugin, may be I need to ask if there is an option to modify ajax request to include visible columns or the entire saveState object.

    Thanks,
    Karmendra

  • colincolin Posts: 9,518Questions: 0Answers: 1,576
    Answer ✓

    Hi @karmendra ,

    Yep, you can add custom properties to the Ajax request as demonstrated in this example here, so that could easily include the visible columns,

    Cheers,

    Colin

  • karmendrakarmendra Posts: 13Questions: 5Answers: 0

    Thanks colin, This is what I was looking for.

This discussion has been closed.