Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

Changes in a function fnAddData() in DataTable (to the following code) has introduced issues with angularJS $resource.query():

    this.fnAddData = function( data, redraw )
    {
        var api = this.api( true );

        /* Check if we want to add multiple rows or not */
        var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
            api.rows.add( data ) :
            api.row.add( data );

        if ( redraw === undefined || redraw ) {
            api.draw();
        }

        return rows.flatten().toArray();
    };

The return object from $resource.query is an array of $resource objects. The check for whether to add the passed object as multiple rows or not fails because $.isPlainObject returns false. The following error is displayed:

DataTables warning: table id=DataTable_Table_1 - Requested unknown parameter 'xyz...' for row 0. For more information about this error please see http://datables.net/tn/4.

Has anyone found a work-around for this, or am I doing something wrong?

share|improve this question
up vote 0 down vote accepted

I ended up logging the bug in their website and using these hacks as a fix for now:

  1. Either: using a container object to hold that array

  2. Or: using JSON.stringify() and JSON.parse() before passing the $resource object to dataTables: -

    var objectToSendToDataTables = JSON.parse(JSON.stringify(data));
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.