1

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?

1 Answer 1

0

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));
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.