unknown parameter '0' for row 0

unknown parameter '0' for row 0

andrekarnerandrekarner Posts: 5Questions: 2Answers: 1

Hi guys,

first of all: sorry for my english!

my problem:

try to run my datatable with ajax datasource (of MVC WebMethod) - unsuccessfully
i always get the error message 'unknown parameter '0' for row 0'

my js:

$('#deletedBanners').dataTable({
"bServerSide": true,
"sAjaxSource": getDeletedBannersUrl,
"bProcessing": true,
"aoColumn": [
{ "sName": "Firma_Nr" },
{ "sName": "Code_Abteilung" },
{ "sName": "DN_ID" },
{ "sName": "CreateUser" }
]
});

my table:

Firma_Nr Code_Abteilung DN_ID CreateUser
Firma_Nr Code_Abteilung DN_ID CreateUser

my cs method which returns an valid formatted json:

var deletedBanners = from b in this.Storage.Entity.banner
where b.Deleted == true
where b.Firma_Nr != null && b.Code_Abteilung != null && b.DN_ID != null
select new {
b.Firma_Nr,
b.Code_Abteilung,
b.DN_ID,
b.CreateUser
};

        return Json(new
        {
            sEcho = param.sEcho,
            iTotalRecords = deletedBanners.Count(),
            iTotalDisplayRecords = deletedBanners.Count(),
            aaData = deletedBanners
        }, JsonRequestBehavior.AllowGet);

my JSON:

{"sEcho":"1","iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":[{"Firma_Nr":"442","Code_Abteilung":"20600110","DN_ID":"8022766810","CreateUser":"admkarneran"}]}

debug:

http://debug.datatables.net/ogonuc

please help - im really desperated!

thanks,

This question has an accepted answers - jump to answer

Answers

  • andrekarnerandrekarner Posts: 5Questions: 2Answers: 1
    edited March 2015

    think ive got the problem -> JSON string!

    current json return string:

    {
    "sEcho": "1",
    "iTotalRecords": 1,
    "iTotalDisplayRecords": 1,
    "aaData": [
    {
    "Firma_Nr": "442",
    "Code_Abteilung": "20600110",
    "DN_ID": "8022766810",
    "CreateUser": "admkarneran"
    }
    ]
    }

    tried it with hardcoded return value of

    aaData = new List<string[]>() {
    new string[] {"1", "Microsoft", "Redmond", "USA"},
    new string[] {"2", "Google", "Mountain View", "USA"},
    new string[] {"3", "Gowi", "Pancevo", "Serbia"}
    }

    which correctly returns this json string:

    {
    "sEcho": "1",
    "iTotalRecords": 1,
    "iTotalDisplayRecords": 1,
    "aaData": [
    [
    "1",
    "Microsoft",
    "Redmond",
    "USA"
    ],
    [
    "2",
    "Google",
    "Mountain View",
    "USA"
    ],
    [
    "3",
    "Gowi",
    "Pancevo",
    "Serbia"
    ]
    ]
    }

    which gets successfully loaded into my datatable!

    difference between json1 and json2:

    json1 entry: { "item1" : "value1" }
    json2 entry: [ "item1" : "value1" ]

    any idea?

  • andrekarnerandrekarner Posts: 5Questions: 2Answers: 1
    Answer ✓

    problem solved: converted my entity object .ToArray(), afterwards select new[] (into array object) - and now datables displays my data :) !

This discussion has been closed.