mRender gives warning: DataTables warning (table id = 'someTypeTable'): Requested unknown parameter

mRender gives warning: DataTables warning (table id = 'someTypeTable'): Requested unknown parameter

ureshkuruhuriureshkuruhuri Posts: 12Questions: 1Answers: 0
edited January 2013 in DataTables 1.9
Hello,

I am looking for some help to avoid the warning -
DataTables warning (table id = 'someTypeTable'): Requested unknown parameter '0' from the data source for row 0 - when am rendering the column(s) using the mRender option.

Versions used as below:
DataTables v1.9.4
jQuery v1.7.1
jQueryUI v1.8.11


Scenarios as below:
Scenario 1:
When am trying to render, using well-formed json data, couple of columns with mRender in order to show a radio button (in one column) and a concatenated information in another column, as below, am getting the warning:

[quote]DataTables warning (table id = 'someTypeTable'): Requested unknown parameter '0' from the data source for row 0[/quote]

[code]
someTypeDataTable = $("#someTypeTable").dataTable({
iDisplayLength: 25,
aaData: jsonData["someTypes"],
aoColumns:[
{"mRender":function(data, type, row){
//console.log(data, ' - ', type, ' - ', row);
var radioBtn = "";
return radioBtn;
}},
{"mData":"someTitle"},
{"mRender":function(data, type, full){
var dimension = full.dimensions + " " + full.uom;
return dimension;
}},
{"mData": "notes"}
],
bProcessing: true,
bRetrieve: true
});
[/code]

Scenario 2:
If I am rendering the datatable with the same json data using mData, it is working fine.

[code]
someTypeDataTable = $("#someTypeTable").dataTable({
iDisplayLength: 25,
aaData: jsonData["someTypes"],
aoColumns:[
{"mData": "someTypeId"},
{"mData": "someTitle"},
{"mData": "dimensions"},
{"mData": "notes"}
],
bProcessing: true,
bRetrieve: true
});
[/code]


Sample jsonData as below:
{"someTypes":
[
{"notes":"N/A","someTypeId":3,"dimensions":"100x100x100","uom":"mm","someTitle":"Steel Box w/ ABC, XYZ 1000"},
{"notes":"N/A","someTypeId":4,"dimensions":"1200x800x145","uom":"mm","someTitle":"WOOD-SQR-STUFF, 100 x 100"},
{"notes":"Height Varies","someTypeId":5,"dimensions":"1130x1200xXXXX","uom":"mm","someTitle":"Plastic & Wool BOX 130x120"}
]}

Please let me know what has to be done to avoid this error or is there a way to suppress the warning.

Thanks,
Uresh

Replies

  • ureshkuruhuriureshkuruhuri Posts: 12Questions: 1Answers: 0
    edited January 2013
    I tried the DataTables debugger and I "liked" it. Great work. :-)

    However, while examining the table properties and other parameters (after debugging), I got to see something different and not sure if this is a bug with mRender option.

    Here below are the observations:

    For each of the Row data (under Rows), I see two more data elements as null for zero-th and second indexes besides the json data provided. e.g. as below
    [code]
    {
    "0": null,
    "2": null,
    "notes": "N/A",
    "someTypeId": 3,
    "dimensions": "100x100x100",
    "uom": "mm",
    "someTitle": "ABC BOX"
    }
    [/code]

    and I think this is what is giving rise to the warning.

    I appreciate any ideas to help fix this issue.

    Thanks,
    Uresh
  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    You should use mData as well if you are using mRender . The result from mData is put into the first parameter passé dint mRender - without it you get a warning.

    Allan
  • ureshkuruhuriureshkuruhuri Posts: 12Questions: 1Answers: 0
    Following your comments, here is what I did:

    [code]
    someTypeDataTable = $("#someTypeTable").dataTable({
    iDisplayLength: 25,
    aaData: jsonData["someTypes"],
    aoColumns:[
    {"mData":"someTypeId", "mRender":function(data, type, row){
    //console.log(data, ' - ', type, ' - ', row);
    var radioBtn = "";
    return radioBtn;
    }},
    {"mData":"someTitle"},
    {"mData":"dimensions", "mRender":function(data, type, full){
    var dimension = full.dimensions + " " + full.uom;
    return dimension;
    }},
    {"mData": "notes"}
    ],
    bProcessing: true,
    bRetrieve: true
    });
    [/code]

    It worked. That's awesome and easy.

    Thank you.
    Uresh
This discussion has been closed.