jquery - How to select two columns data from the table? -


i using datatable plugin.

i select 2 columns of table , array further processing.

from $.post() call json in following form:

{"secho": 26,  "itotalrecords": 26,  "itotaldisplayrecords": 10,  "aadata": [[ "20090301","60"],             [ "20090302","253"],             [ "20090303","108"],             [ "20090304","166"], ... [snip] ...             [ "20090327","209"],             [ "20090328","452"],             [ "20090329","450"],             [ "20090330","143"]             ],  "aocolumns": [{"stitle": "the observed date"},                {"stitle": "number of objects"}               ] } 

then show table as:

$('#querytable').datatable(jsondata); 

where

<table class="display" id="querytable"></table> 

i add click event on column of table return me javascript array.

how whole column in data table?

something work:

    var mytable = $("#querytable").datatable(     {         "aadata": mydata,         "aocolumns": mycolumns     } ); mydataarray = mytable.fngetdata();  mycolumnarray = [] $("#querytable thead tr th").click(function()     {         var index = $(this).index();         (var = 0; < mytable.fnsettings().fnrecordstotal(); i++)         {             mycolumnarray[i] = mydataarray[i][index];         }     } ); 

here working example: http://jsfiddle.net/srmzr/5/ . click on column headers array of data column.


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -