Requested unknown parameter '0' from the data source for row '0'

Requested unknown parameter '0' from the data source for row '0'

afarberafarber Posts: 53Questions: 0Answers: 0
edited May 2013 in General
Does anybody please know, what is wrong with the very simple HTML file below?

The screenshot can be seen at
http://stackoverflow.com/questions/16539578/datatables-warning-requested-unknown-parameter-0-from-the-data-source-for-row

I am just trying to use an array of objects as the data source for DataTables:

[code]









var data = [
{"Name":"UpdateBootProfile","Result":"PASS","ExecutionTime":"00:00:00","Measurement":[]},
{"Name":"NRB Boot","Result":"PASS","ExecutionTime":"00:00:50.5000000","Measurement":[{"TestName":"TOTAL_TURN_ON_TIME","Result":"PASS","Value":"50.5","LowerLimit":"NaN","UpperLimit":"NaN","ComparisonType":"nctLOG","Units":"SECONDS"}]},
{"Name":"NvMgrCommit","Result":"PASS","ExecutionTime":"00:00:00","Measurement":[]},
{"Name":"SyncNvToEFS","Result":"PASS","ExecutionTime":"00:00:01.2500000","Measurement":[]}
];

$(function() {
var testsTable = $('#tests').dataTable({
bJQueryUI: true,
aaData: data,
aoColumns: [
{ mData: 'Name' },
{ mData: 'Result' },
{ mData: 'ExecutionTime' }
]
});
});








Name
Result
ExecutionTime








[/code]

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    mData was introduced in v1.9.4 (it was called mDataProp before). So the problem is that you are using an out of date version of DataTables.

    http://live.datatables.net/ugizod/edit#javascript,html

    Allan
  • afarberafarber Posts: 53Questions: 0Answers: 0
    Thank you!
  • afarberafarber Posts: 53Questions: 0Answers: 0
    edited May 2013
    I'm trying to render results in red, green or black color now using the mData:

    http://live.datatables.net/ocavik/edit#source

    But get a new error message:

    [quote]
    DataTables warning (table id = 'tests'):
    Requested unknown parameter {mData function} from the data source for row 0
    [/quote]

    Any suggestions please? Below is my new code:

    [code]
    var data = <?= json_encode($data) ?>;

    function renderResult(data, type, val) {
    if (type === 'set') {
    if (val === 'PASS') {
    data.display = '' + val + '';
    } else if (val === 'FAIL') {
    data.display = '' + val + '';
    } else {
    data.display = val;
    }

    data.result = val;
    return;
    }

    if (type === 'display') {
    return data.display;
    }

    // for type = sort, type, filter and undefined
    return data.result;
    }

    $(function() {
    var testsTable = $('#tests').dataTable({
    bJQueryUI: true,
    aaData: data,
    aoColumns: [
    { mData: 'Name' },
    { mData: renderResult },
    { mData: 'ExecutionTime' }
    ]
    });
    });
    [/code]
  • afarberafarber Posts: 53Questions: 0Answers: 0
    Ok, I probably shouldn't use the val argument in my renderResult function at all?

    http://live.datatables.net/ocavik/5/

    Regards
    Alex
This discussion has been closed.