Newbie Question - fnReloadAjax [object Object]

Newbie Question - fnReloadAjax [object Object]

rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
edited January 2012 in General
I am new to most of this - but I think I am fairly close - fnReloadAjax gets called and appears to populate 1 row of the datatable (should be more than the 1) with the exception that I am getting the [object Object] as the data in the fields.... Any help would be greatly appreciated... code is as follows.

[code]
$(document).ready(function() {

$.fn.dataTableExt.oApi.fnReloadAjax = function(oSettings, sNewSource){
oSettings.sAjaxSource = sNewSource;
this.fnClearTable(this);
this.oApi._fnProcessingDisplay(oSettings, true );
var that = this;

$.getJSON(oSettings.sAjaxSource, null, function(json){

/* Got the data - add it to the table */
for (var i=0; i

Replies

  • rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
    edited January 2012
    Oh - also - thought that adding a snippet of the json might be useful ...
    { "aaData":[[ { "unit":"1", "status":"A", "duration":"07:12:19", "response":"", "destination":"" }, { "unit":"2", "status":"A", "duration":"01:32:17", "response":"", "destination":"" }]]}
  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    What you want is mDataProp :-). Have a look at this blog post for more details: http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
  • rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
    edited January 2012
    Having a look
  • rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
    edited January 2012
    I am trying to use the mDataProp - and it looks promising - at least I have a different symptom...

    The error is (DataTables warning (table id = 'table'): Requested unknown parameter 'unit' from the data source for row 0)

    Thanks BTW - datatables looks great - I know it probably sounds pretty bad - but I'm lost - still looking through it though.

    Current Code:

    [code]
    var oTable;

    $(document).ready(function() {

    $.fn.dataTableExt.oApi.fnReloadAjax = function(oSettings, sNewSource){
    oSettings.sAjaxSource = sNewSource;
    this.fnClearTable(this);
    this.oApi._fnProcessingDisplay(oSettings, true );
    var that = this;

    $.getJSON(oSettings.sAjaxSource, null, function(json){

    for (var i=0; i
  • rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
    Think I have it - but I don't know why - will post code in a minute
  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    > "aaData":[[

    aaData is a 2D array of objects. I think what you are actually looking for is a 1D array of objects is it not? i.e. each row is an object in the array.

    Allan
  • rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
    That was it - late I guess... Thanks for the quick response -
    BTW - same code except it won't take duration? does that have to do with the ':"?
  • rpmatthewrpmatthew Posts: 13Questions: 0Answers: 0
    Found it - thanks allan - you are GREAT - really saved me.... AWESOME work
This discussion has been closed.