JQuery Datatable adding a row with mdata array

I have a datatable which gets its data over mData.

var processURL="path"
    $.ajax(
        {
        type        : "GET",
        url         : processURL,
        cache       : false,
        dataType    : "json",
        success     : function (d) 
            {       
            var oTable = $('#Testtable').dataTable();
            oTable.fnDestroy();
            //Tabelle zu Datentabelle
            $('#Testtable').dataTable(
                        {
                        bJQueryUI: true,
                        "sScrollY": "200px",
                        "bPaginate": false,
                        "sDom": "frtiS",
                        "aaSorting": [[ 2, "asc" ]],
                        "bDeferRender": true,
                        "aaData": d.COMMENT,
                        "aoColumns":    
                            [
                            { "mData": "KOMMENTARTYP" },
                            { "mData": "a" },
                            { "mData": "b" },
                            { "mData": "c" },
                            { "mData": "d" },
                            { "mData": "e" },
                            { "mData": "f" }
                            ],
                        "aoColumnDefs": 
                            [ 
                                { 
                                "sClass": "hide_me", "aTargets": [ 6 ]
                                } 
                            ]

                        }).makeEditable(
                            {
                            sUpdateURL: function(value, settings)
                                {
                                alert(CommentIDuebergabe);
                                alert(value);

                                return(value);
                                }
                            });

            var oTable1 = $('#Testtable').dataTable();
            oTable1.fnStandingRedraw();                   
            },              
        error : function (d) 
            {                       
            alert('error');
            }
        });

It works fine but if I add data with fnAddData like this:

function adddata()
    {
    $('#KommentareTabelle').dataTable().fnAddData(
            [
            "1. Spalte",
            "2. Spalte",
            "3. Spalte",
            "4. Spalte",
            "5. Spalte",
            "6. Spalte",
            "7. Spalte"  
            ])
    }

I get an error " unknown parameter'KOMMENTARTYP' in data source.

If I add data like this in a normal datatable without mdata it works.

Where is the Problem?

Answers


Here is the solution: If you want to add data to a mdata Jquery Table you have to use the same array which you used in mdata:

function adddata() 
    {
    oTable = $('#KommentareTabelle').dataTable();
    oTable.fnAddData(
        [
            {
            "KOMMENTARTYP":        "Zeile 0", 
            "a":                   "Zeile 1",
            "b":                   "Zeile 2",
            "c":                   "Zeile 3",
            "d":                   "Zeile 4",
            "e" :                  "Zeile 5",
            "f" :                  "Zeile 6"
            }
        ]); 
    }

Need Your Help

Django jpg thumbnail generation blocked in production

django easy-thumbnails

I am using easy-thumbnails to generate thumbnails for images uploaded. In the dev environment, thumbnails are properly generated and uploaded to S3 for png and jpg files. However, in production, only

How to instantiate route in a Polymer app located on an internal page of a site using page.js

html url-routing web-component polymer-1.0 page.js

I'm attempting to run a Polymer app on an internal page of a site and having an issue setting the initial route. The app is located at 127.0.0.1:8080/hardware on local dev.