Cannot add new row to datatable. "Requested unknown parameter"

Cannot add new row to datatable. "Requested unknown parameter"

renzrenz Posts: 1Questions: 1Answers: 0

Hello,
I am new to DataTables and I am having problems in dynamically adding a new row to the datatable.

Here is my initialization:

        table = $("#college-list").DataTable({
               'ajax': {
                          'url': 'admin/get_college',
                          'type': 'GET'
                },
                'columns': [
                            { 'data': 'college_abbrev', "bSortable": true  },
                            { 'data': 'college_name' , "bSortable": true },
                            {
                                "mData": null,
                                "bSortable": false,
                                "mRender": function(data, type, college) {
                                  return '<button type="button" class="btn btn-primary edit-college table-condensed">Edit</button>'
                                           +'<button data-id="' + college.college_id  + '" type="button" class="delete-college btn btn-primary table-condensed" href="">Delete</button>';
                                }
                             }
                ]
        });

Here is the sample code that I am using when adding a new row (ca, cn, and college_id are variables):

                        table.row.add( [
                            {
                                    "college_abbrev": ca,
                                    "college_name": cn,
                                    "button":'<button type="button" class="btn btn-primary edit-college table-condensed">Edit</button>'
                                           +'<button data-id="' + college_id  + '" type="button" class="delete-college btn btn-primary table-condensed" href="">Delete</button>'
                            }
                        ] ).draw();

It creates a row but the columns are empty except for the buttons and it gives the following error:

DataTables warning: table id=college-list - Requested unknown parameter 'college_abbrev' for row 17

How do you add a new row?

Answers

  • zeebeezeebee Posts: 3Questions: 1Answers: 0
    edited July 2015

    did you find any solution of this problem?

This discussion has been closed.