Colvis + ServerSide -> only load visible columns
Colvis + ServerSide -> only load visible columns

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
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
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.
Using
ajax.data
as a function you could usecolumns().visible()
to get the column visibility and send that as a parameter in the server side request.Kevin