Colvis + ServerSide -> only load visible columns

Colvis + ServerSide -> only load visible columns

Dani10Dani10 Posts: 2Questions: 1Answers: 0

Hi.
We use Colvis and we would like to load only the visible columns from the server. (because some columns are pretty expensive to compute)
So everytime the user changes the colvis-option, the table should redraw and load the visible columns only.

Is this possible? How can we tell the server which columns it should return? The columns are reorderable, so an ID would probably not suffice.

Initially we use colvis with:

buttons: [{
extend:"colvis",
columns: ":gt(1)"
}]

Thanks for the help.

Answers

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

    Hi @Dani10 ,

    That's not possible, I'm afraid. Even if the columns are hidden, DataTables needs to know the data for the entire row.

    Cheers,

    Colin

  • Dani10Dani10 Posts: 2Questions: 1Answers: 0

    To send the whole row is no problem. I can send empty values for all hidden columns.
    But on the server side i need to know which columns are shown. So i can compute only these ones.

  • kthorngrenkthorngren Posts: 21,146Questions: 26Answers: 4,918

    Using ajax.data as a function you could use columns().visible() to get the column visibility and send that as a parameter in the server side request.

    Kevin

This discussion has been closed.