Can you get data from a non-visible column?

Can you get data from a non-visible column?

kevins1966kevins1966 Posts: 6Questions: 4Answers: 0

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

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    though table.rows({ filter: 'applied' }).column(0).data() does return data, it returns the full unfiltered dataset set whereas

    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. Use pluck() to get a particular column from table.rows({ filter: 'applied' })).data().

    .column('hide').data()

    Use the jQuery class selector with a preceding .. For example:

    table.column('.hide').data()
    

    Kevin

Sign In or Register to comment.