How to edit previously loaded data (with AJAX) in a DataTable

How to edit previously loaded data (with AJAX) in a DataTable

HugoTavaresHugoTavares Posts: 1Questions: 1Answers: 0
edited August 2014 in Free community support

Currently I'm fetching data from a REST web service with this call that outputs my jsonData, that will be used like this.

    var t = $('#newAttributes').DataTable({
        data: jsonData,
        columns: [
                  { data: 'jsonId' },
                  { data: 'jsonName' },
                  { data: 'jsonRef' }
              ],
        stateSave: true 
    });

Just like here: http://datatables.net/manual/data#Objects

I tried it out, and it works perfectly but I cannot change the fields' content.

Then, after, I tried filling the input fields "manually", so this was the code I got:

    var t = $('#newAttributes').DataTable({

        stateSave: true 
    });


    $('#show_button').on('click', function (args) {
        for(var i=0;i<args.length;i++){
            var obj = args[i];

            t.row.add([
                       '<input type="text" name="id" value="'+ obj['jsonId'] +'"/>',
                       '<input type="text" name="name" value="'+ obj['jsonName'] +'"/>',
                       '<input type="text" name="ref" value="'+ obj['jsonRef'] +'"/>'
                       ]).draw();

            ++t.attrId; 
        }
    });

    $('#show_button').click($jsonData); // show_button is hidden

This solution was based on other solution I built following this: http://datatables.net/examples/api/form.html

And also... it's not working.

Does anyone got this issue and solved it?

Thank you in advance.

This discussion has been closed.