Empty Data Source causes "requested unknown parameter"

Empty Data Source causes "requested unknown parameter"

ckapatchckapatch Posts: 5Questions: 0Answers: 0
edited October 2012 in General
I have a datatable setup like such:

[code]
var oTable = $('#documentList').dataTable({
"bPaginate": true,
"iDisplayLength": 50,
"bFilter": true,
"aaSorting": [[ 3, "asc" ]],
"sDom": 'tr<"F"ip>',
"sPaginationType": "bootstrap",
"bProcessing" : true,
"bServerSide": true,
"sAjaxSource": "/Document/GetDocuments/",
"sServerMethod": "POST",
"sDefaultContent": "",
"fnServerParams": function (aoData) {
aoData.push(
{ "name": "isRefresh", "value": true },
{ "name": "projectId", "value": "69606992-3aea-4b4e-9e0b-a0bcb19f68eb" }
);
},
"aoColumns":
[
{
"mData": "DocumentId",
"bVisible": false,
"sName": "DocumentId"
},
{
"mData": null,
"sDefaultContent" : "",
"mRender" : function (data, type, full) {
return '';
}
},
{
"mData": null,
"bSortable": false,
"sDefaultContent": "",
"mRender": function (data, type, full) {
return ''
+ ''
+ '';
}
},
{
"mData": "DocumentNumber",
"sName": "DocumentNumber",
"sTitle": "Document Number"
},
{
"mData": "Title",
"sName": "Title",
"sTitle": "Title"
},
{
"mData": "DateUpdated",
"sName": "DateUpdated",
"sTitle": "Date Updated"
}
],
"fnDrawCallback": function (oSettings) {
$('.icon-edit').tooltip({
"title": "Edit the document"
});

$('.icon-remove').tooltip({
"title": "Move document to trash"
});

$('.icon-eye-open').tooltip({
"title": "View the document details"
});
}
});

[/code]

If I remove these two empty data source columns:

[code]
{
"mData": null,
"sDefaultContent" : "",
"mRender" : function (data, type, full) {
return '';
}
},
{
"mData": null,
"bSortable": false,
"sDefaultContent": "",
"mRender": function (data, type, full) {
return ''
+ ''
+ '';
}
},
[/code]

Everything is great, but leave them in and I get the classic "DataTables warning (table id = 'documentList'): Requested unknown parameter from the data source for row 0.

Any idea what I'm doing incorrect?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    That should work just fine: http://live.datatables.net/odigos/edit#javascript,html .

    Are you using DataTables 1.9.4?

    Allan
  • ckapatchckapatch Posts: 5Questions: 0Answers: 0
    Hi Allan,

    Thanks for the reply.

    Yes I'm using the latest DataTables version. I'll continue to poke around and see what's going on. I'll try the above example with my environment and make sure that it works.
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    Did you verify the number of columns sent back from your server side script? Is that matching with the number of inclusive of hidden ones?
    Just a Sanity check
  • ckapatchckapatch Posts: 5Questions: 0Answers: 0
    edited November 2012
    Hi Girishmr.

    Yes, like I said if you remove the two definitions from the javascript, everything functions as normal.

    thank you for the comment. I'm still digging around on this.

    Happy Halloween!
  • ckapatchckapatch Posts: 5Questions: 0Answers: 0
    Here's the response from my web server:

    {
    "sEcho": 1,
    "iTotalRecords": 1000,
    "iTotalDisplayRecords": 1000,
    "aaData": [
    {
    "DocumentId": "22323232",
    "DocumentNumber": "000000-SUBPROJID-EQID-(SOURCE)DOCTYPE-001",
    "Title": "Document Title",
    "DateUpdated": "/Date(1351732826064)/"
    }
    ],
    "sColumns": "DocumentId,DocumentNumber,Title,DateUpdated"
    }
  • ckapatchckapatch Posts: 5Questions: 0Answers: 0
    figured it out. I was missing the two columns in the "sColumns" when I returned the json.

    Thanks all for your help.

    CK
This discussion has been closed.