aaData JSON data returned how can I disect this?

aaData JSON data returned how can I disect this?

AndyManAndyMan Posts: 7Questions: 1Answers: 0
edited December 2012 in DataTables 1.9
Hi,

I have been working with and learning DataTables for a short time.

I can upload a .csv table to a folder on my server and then build a table (with DataTables) dynamically. to display on my browser. This is all well and good, but I need to work with the data as it comes back for display on my page.

I can see the object and examine it with FireBug

I want to use the "aaData" object and some of the returned data.

Is there an example or tutorial with DataTables on how to work with aaData?

Andy..

Replies

  • AndyManAndyMan Posts: 7Questions: 1Answers: 0
    My Call to get my table is below..


    $('#example').dataTable( {
    "sScrollY": 200,
    "sScrollX": "100%",
    "sAjaxSource": "getPage.php",
    "fnServerParams": function ( aoData ) {
    aoData.push( { name: "file", value: myVal} );
    },
    "bInfo": true,
    "bFilter": true,
    "bDestroy": true,
    "bSort": true
    } );
    });

    I found a call where steve_at_ventus seems to be working with the response..

    $('#tickets_active_table').dataTable({

    "aaData": response,
    "bProcessing": true,

    Andy
  • AndyManAndyMan Posts: 7Questions: 1Answers: 0
    Was unable to figure out how to work with the JSON aaData object. Tried to loop through my table instead after the table was rendered with frustrating results.

    This table will be used to construct a graphics layer on a map.
    CityName, State lat, lon
    Greensboro, NC, 36.079, -79.803
    Raleigh, NC, 35.777, -78.639
    Richmond, VA, 37.541, -77.439
    Salisbury, MD, 38.36, -75.598



    $(document).ready(function () {

    $('#fileupload table')
    .delegate('a','click', function(e) {
    e.preventDefault(); //prevents the link from downloading the file..
    var $url = $(this); //Gets you the address off of the link.
    $url = $url.attr('href').split('/'); //Splits off the url on the final '/' mark
    $url = $url[$url.length - 1];

    var myVal = "server/php/files/" + $url;


    $.getJSON('getPage.php', {file:myVal,returnheader:'1',iDisplayStart:0,iDisplayLength:0 },function( oData, textStatus, jqXHR ){
    $('#tableContainer thead > tr:first-child').html( '' + oData.aaData[0].join('') + '' );

    $('#example').dataTable( {
    "sScrollY": 200,
    "sScrollX": "100%",
    "sAjaxSource": "getPage.php",
    "fnServerParams": function ( aoData ) {
    aoData.push( { name: "file", value: myVal} );
    },
    "bInfo": true,
    "bFilter": true,
    "bDestroy": true,
    "bSort": true
    });

    /* At this point the table has been constructed
    * I need to loop through the columns and the rows
    * I will first create an array of the column names and look for coordinate containing columns. */



    /*oddly enough without this fragment of code I could not get the msgs to fire off in the "rows.each" loop below*/

    var myCols = $('#example th:gt(0)');
    alert ('myCols.length: ' + myCols.length);
    myCols.each(function(index){

    });


    var rows = $("#example tr:gt(0)");
    var rowNum = 0;
    //var rows = $("#example tr");

    rows.each(function(index){
    alert('rows function');
    var sMessage = '';
    var tblrowArray = $('td', this);
    for (i=0; i
This discussion has been closed.