DataTables warning (table id = 'example')..... on Update from Editor

DataTables warning (table id = 'example')..... on Update from Editor

lowrymellowrymel Posts: 20Questions: 4Answers: 0
edited September 2012 in Editor
Hi Allan,

I get the following error from an Update on Editor.

DataTables warning (table id = 'example'): Requested unknown parameter {mData function} from the data source for row 1

I am using aoColumnDefs exclusively and match my server data AFAIK.

Here is the debug info

http://debug.datatables.net/enebov


and here is a code snip

[code]


"aoColumnDefs":
[

//--------------------------------------------------------------------------------
{ "aTargets":[0],
"sTitle": "Product Description",
"sClass": "left",
"sWidth": "1000px" ,
"mDataProp": "description"

},
//--------------------------------------------------------------------------------
{ "aTargets":[1],
"sTitle": "Unit Cost",
"sClass":"right",

"mDataProp": function ( data, type, val ) {
if (type === 'set') {
// Store the base value
data.cost = val;

// Display is formatted with a dollar sign and number formatting
data.cost_display = val==="" ? "" : '$' + RenderDecimalNumber(val);

// Filtering can occur on the formatted number, or the value alone
data.cost_filter = val ;
return;
}
else if (type === 'display') {
return data.cost_display;
}
else if (type === 'filter') {
return data.cost_filter;
}
// 'sort', 'type' and undefined all just use the integer
return data.cost;

},

// custom render in cell
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
$(nTd).css('text-align', 'right')
}


},
//--------------------------------------------------------------------------------
{ "aTargets":[2],

"mDataProp": function ( data, type, val ) {
if (type === 'set') {
// Store the base value
data.margin = val;

// Display is formatted with a dollar sign and number formatting
data.margin_display = val==="" ? "" : RenderDecimalNumber(val) + "%"; //numberFormat(val);

// Filtering can occur on the formatted number, or the value alone
data.margin_filter = val ;
return;
}
else if (type === 'display') {
return data.margin_display;
}
else if (type === 'filter') {
return data.margin_filter;
}
// 'sort', 'type' and undefined all just use the integer
return data.margin;

},

// custom render in cell
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
if( oData.margin > 20) {
$(nTd).css('color', 'green')
$(nTd).css('text-align', 'right')
} else {
$(nTd).css('color', 'red')
$(nTd).css('text-align', 'right')
}
}


},
//--------------------------------------------------------------------------------
{ "aTargets":[3],
"sClass":"right",

"mDataProp": function ( data, type, val ) {
if (type === 'set') {
// Store the base value
data.markup = val;

// Display is formatted with a dollar sign and number formatting
data.markup_display = val==="" ? "" : RenderDecimalNumber(val) + "%"

// Filtering can occur on the formatted number, or the value alone
data.markup_filter = val;
return;
}
else if (type === 'display') {
return data.markup_display;
}
else if (type === 'filter') {
return data.markup_filter;
}
// 'sort', 'type' and undefined all just use the integer
return data.markup;

},

// custom render in cell
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
$(nTd).css('text-align', 'right')
}
},
//--------------------------------------------------------------------------------
{ "aTargets":[4],

"mDataProp": function ( data, type, val ) {
if (type === 'set') {
// Store the base value
data.price = val;

// Display is formatted with a dollar sign and number formatting
data.price_display = val==="" ? "" : "$"+RenderDecimalNumber(val); //numberFormat(val);

// Filtering can occur on the formatted number, or the value alone
data.price_filter = val //==="" ? "" : data.price_display+" "+val;
return;
}
else if (type === 'display') {
return data.price_display;
}
else if (type === 'filter') {
return data.price_filter;
}
// 'sort', 'type' and undefined all just use the integer
return data.price;

},

// custom render in cell
"fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
{
$(nTd).css('text-align', 'right')
}
}
//--------------------------------------------------------------------------------

],

"oTableTools": {
"sRowSelect": "single",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}

}
);







[/code]

2nd question.
In the above code the "sClass":"right" is not working. It was neccessary to do the fnCreatedCell workaround.
What I am doing wrong here?


Any help is greatly appreciated.

Thanks!

Replies

  • allanallan Posts: 55,883Questions: 1Answers: 8,835 Site admin
    > In the above code the "sClass":"right" is not working. It was neccessary to do the fnCreatedCell workaround.

    Do you have something like `.right { text-align: right }` in your CSS?

    > DataTables warning (table id = 'example'): Requested unknown parameter {mData function} from the data source for row 1

    The code looks like it should work. Can you give me a link to the page please? I'd suggest console.log-ing your mData function returns - I would guess one of them is undefined, but I can't see which one it would be from the above code.

    Allan
This discussion has been closed.