Base solution for your next web application
Open Closed

Simple Datatables not working #11248


User avatar
0
marble68 created

Version 11, MVC

I cloned the getall method and the api works great.

I see my data coming back.

I created a table with one column, copied the datatables method from the page, removed all the columndefs except for one...

And no matter what I'm getting the infamous Requested unknown parameter '0' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

My results look fine, I have an items array with a list of objects.

Does anyone have a suggestion on how to troubleshoot why this is not working?

My table:

  <table id="MyRecordStateTable" class="table dataTable align-middle gs-0 gy-3">
                                <!--begin::Table head-->
                                <thead>
                                    <tr>
                                        <th class="p-0 w-50px"></th>
                                    </tr>
                                </thead>
                                <!--end::Table head-->
                                <!--begin::Table body-->

                                <!--end::Table body-->
                            </table>

My datatables:

  var dataTable = _$myRecordStateTable.DataTable({
            paging: false,
            serverSide: true,
            processing: true,
            listAction: {
                ajaxFunction: abp.services.app.recordStates.getAllForUserId,
                inputFilter: function () {
                    return {
                        userId: _userid
                    }
                },
                columnDefs: [
                    { "defaultContent": "-", "targets": "_all" },
                    //{ targets: 0, data: 'fullName'},
                ]
            }
        });

What my items in the array of 'items' look like:

{
  "recordState": {
    "state": 2,
    "notes": "",
    "recordId": "08da5a0b-e079-4edb-8ebb-17fcb45292ae",
    "recordCategoryId": "08da5a0b-deaf-4372-87a1-2320eb5fbc2f",
    "userId": 10,
    "recordStatusId": "08da5a0b-df28-4ff8-829c-185c1a27586f",
    "id": "0c252a48-8208-a9cf-06dc-3a04c3460dcc"
  },
  "recordStatus": {
    "statusName": "Accepted",
    "htmlColor": "#67c777",
    "csscLass": "",
    "isDefault": false,
    "tenantDepartmentId": null,
    "id": "08da5a0b-df28-4ff8-829c-185c1a27586f"
  },
  "recordfilename": "auto insurance.pdf",
  "recordCategoryName": "Auto Insurance",
  "userName": "Marble 68",
  "recordStatusStatusName": "Accepted",
  "fullName": "Marble 68",
  "userId": 10
}

I get multiple of these, and yet, no matter what, I'm getting that error.

I tried adding this, from the generated page:

        _$myRecordStateTable
            .on('xhr.dt', function (e, settings, json, xhr) {
                console.log('data back');
                //sortingUser = settings.rawServerResponse.sortingUser;
                dataTable.rawData = settings.rawServerResponse;
                //debugger;
            });

Any advice of things I should check? I'm beating my head against the wall on this.

Thanks in advance for any advice!


1 Answer(s)
  • User Avatar
    0
    marble68 created

    Found it - My columndefs were under my listaction.

    Yet another instance of a missing curley bracket.