Get all Data table into an Array

Get all Data table into an Array

infantheartlyjesinfantheartlyjes Posts: 9Questions: 0Answers: 0
edited October 2012 in General
Hi, I having 25 records in my DataTable. I paginated with 5 records per page. I need all table records data as comma separated data in my array. For example i having 3 columns.
xxx yyy 1
eee fff 2
...
...
...

I need all data as xxx,yyy,1,eee,fff,2 ....... in a array variable? How can i do this ?

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Use fnGetData ?
  • infantheartlyjesinfantheartlyjes Posts: 9Questions: 0Answers: 0
    I need all records of table. In that example It gets only clicked row data ( Specific Row ). I need to get like looping from first record to last record of the table.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > I need all records of table

    The documentation for fnGetData says:

    > Get the data for the whole table, an individual row or an individual cell based on the provided parameters.

    Sounds like that's what you want to me...
  • infantheartlyjesinfantheartlyjes Posts: 9Questions: 0Answers: 0
    to Get table data i tried this code. But click event also not working now.
    [code]$(document).ready(function() {
    oTable = $('#example').dataTable();

    oTable.$('table').click( function () {
    var sData = oTable.fnGetData( this );

    alert( 'The cell clicked on had the value of '+sData );
    } );
    } );[/code]
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    edited October 2012
    Do you have table's inside your table? That's the only way that click event is going to work. Also why pass in 'this' to fnGetData. I'm not sure how the documentation could be any more clear? Don't pass anything into fnGetData and you get the data for the whole table: http://live.datatables.net/etufog/edit#javascript,html
  • infantheartlyjesinfantheartlyjes Posts: 9Questions: 0Answers: 0
    edited October 2012
    Thanks a lot :) Its Works fine... But this function returns the table data as comma delimiter. Since my table data can also has comma there raises a problem when processing the data. So i want the function to return the values as tilde (~) delimiter.
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    > But this function returns the table data as comma delimiter

    No - it returns it as an array. The alert() converts the array of comma delimited.
This discussion has been closed.