Can you get data from a non-visible column?
Can you get data from a non-visible column?
Hi all,
I have an asp.net core application using DataTables with filters, paging and a button to export the data.
I have set up the dataset to have a the first column not visible to users, with class 'hide'.
I have set up the DataTable with the following configuration
columnDefs: [
{
target: 'hide',
visible: false,
searchable: false
}
This succeeds in making the column invisible however when I attempt to view the data using table.rows({ filter: 'applied' }).column('hide').data()
I get nothing despite the fact that table.rows({ filter: 'applied' }).column(0).data()
does.
Also, though table.rows({ filter: 'applied' }).column(0).data()
does return data, it returns the full unfiltered dataset set whereas `table.rows({ filter: 'applied' }).count()' gives a smaller array with just bthe filtered data I was expecting
What am I misunderstanding about the functionality ?
Thanks
Answers
What is happening with this statement is
rows({ filter: 'applied' })
fetches the rows that are filtered and returns a Datatables API with the result. The.column(0).data()
uses the API returned but does not use the API results. These are independent API calls. Usepluck()
to get a particular column fromtable.rows({ filter: 'applied' })).data()
.Use the jQuery class selector with a preceding
.
. For example:Kevin