How to get all of the values in a single column?

How to get all of the values in a single column?

dlbarrondlbarron Posts: 23Questions: 1Answers: 0
edited January 2013 in General
How do I get all of the values of a single column from a multipage DataTable?

I have tried fnGetData(0) which returns the first row of the table. I've also tried fnGetData(), which returns everything. But how do I get all of the values in column 0 (or 1 or 2) for all of the rows in the table?

Thanks

Replies

  • dlbarrondlbarron Posts: 23Questions: 1Answers: 0
    A followup question.
    I need to pass the values to a servlet using ajax so what is the best way to do that? Do I need to format the values of the column into JSON and pass that to the servlet, or is there another way that works better (better meaning more simply).

    Thanks again
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Currently you need to use a plug-in: http://datatables.net/plug-ins/api#fnGetColumnData

    > I need to pass the values to a servlet using ajax so what is the best way to do that?

    With fnServerParams (assuming you are using DataTables to Ajax load the data).

    Allan
  • dlbarrondlbarron Posts: 23Questions: 1Answers: 0
    I'm not trying to send the data to populate the table. The table is already loaded and I need to send it in order to save the selections and changes that have been made. I don't see how fnServerParams would help me there.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    It wouldn't :-). I misunderstood.

    You'd need to make your Ajax call to the server in the standard jQuery way with the information you want to send, so it can save and update state on the server.

    Allan
  • dlbarrondlbarron Posts: 23Questions: 1Answers: 0
    How about this? Is there a way to find out how many total rows there are in a table? Then I can parse the data for each row as I need it.
  • dlbarrondlbarron Posts: 23Questions: 1Answers: 0
    Never mind, I pieced it together from other sources:
    var oSettings = $('#datatable').dataTable().fnSettings();
    var rowCount = oSettings.fnRecordsTotal();
    var a = [];
    for(var i=0;i
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    There is also the fnPagingInfo plug-in to give information about paging: http://datatables.net/plug-ins/api#fnPagingInfo

    Allan
This discussion has been closed.