Trouble with data-order and adding dynamic data

Trouble with data-order and adding dynamic data

maddoxdew27maddoxdew27 Posts: 2Questions: 1Answers: 0
edited January 2016 in Free community support

I am using v1.9, but the issue exists in 1.10 too. I am dynamically updating rows in my DataTable, and I want to add/update the data-order attribute dynamically. I've looked at other questions and thought I had the correct code, but I'm getting a Requested unknown parameter '[object Object]' error now when I go to dynamically update the rows.

I've replicated the issue at https://jsfiddle.net/ezao7vco/4/ . In the JS, you'll have to scroll down to get to my DataTables init code, and where I'm updating the data. I had to add in the bootstrap code manually at the top of the JS for the fiddle.

What am I doing wrong with my columnDefs and my row updater?

Additionally, I am sometimes getting a "out of memory" error when I run this same JS fiddle code on a local page - but that could be due to outside factors since I haven't been able to replicate THAT error in JS Fiddle.

The code is in the fiddle, but I am defining the sort column for my columnDefs

columnDefs: [
    {
        targets: 0,
        data: {
            _: "0.display",
            sort: "0.@data-order",
            type: "0.@data-order"
        }
    },

and then adding/updating data like this:

var myrow = mytable.row("#row-1");
var rowdata = myrow.data();
rowdata[1] = 'a revised b value';
rowdata[2] = 'a revised c value';
myrow.data(rowdata);

$row = myrow.nodes().to$();
$('.my-first-column', $row).attr('data-order', 'special order value');

Answers

  • maddoxdew27maddoxdew27 Posts: 2Questions: 1Answers: 0

    If I remove the columnDefs, and simply add the data-order attribute to the existing td elements, I get the same Requested unknown parameter '[object Object]' error when I go to update the row data with myrow.data().

  • carranthuohill3carranthuohill3 Posts: 4Questions: 1Answers: 1

    The line myrow.data(rowdata); caused the error. It should be:

    var rowdata = myrow.data();
    rowdata[1].display = 'a revised b value';
    rowdata[2].display = 'a revised c value';
    myrow.data(rowdata);
    
This discussion has been closed.