0

I have a DataTable that is using jEditable so that the user can modify the values held in the 3rd column. The user can only edit column 3 values but looking at the AJAX post it is not sending the 'ID' which is the value held in column 1. Looking at Firebug I see the following during a POST:

column  2

id  district

row_id  null

value   new text

Here is my code, I would like to add a line to the RETURN portion so that it return with the value of the first column [0] for (this)? Not sure how to do this, pretty new to Javascript...

<script>
$(document).ready(function() {
/* Init DataTables */
var oTable = $('#district').dataTable();

/* Apply the jEditable handlers to the table */
$('#district', oTable.fnGetNodes()).editable( 'editable_ajax.php', {
    "callback": function( sValue, y ) {
        var aPos = oTable.fnGetPosition( this );
        oTable.fnUpdate( sValue, aPos[0], aPos[1], aPos[2] );
    },
    "submitdata": function ( value, settings ) {
        return {
            "row_id": this.parentNode.getAttribute('id'),
            "column": oTable.fnGetPosition( this )[2]
        };
    },
    "height": "14px"
} );
} );
</script>
1
  • Figured out the issue, simply set a variable to the value in column 1 [0] and then returned the value in the POST. var id2 = oTable.fnGetData( aPos2[0] ); Commented Feb 2, 2012 at 19:57

3 Answers 3

1

When using a version 2+ (as time of writing no download is privided on the website but the latest stable seems to be 2.0.7, just copy the file from the sources...), you can do this approach, as Jovan (creator) pointed out in this bug report:

var currentKey = '';

$('#example').dataTable().makeEditable({

    fnOnEditing: function(input) {  
        currentKey = input.parents("tr").children("td:first").text();
        return true;
    },

    oUpdateParameters: { 
        key: function() { 
            return currentKey; 
        } 
    }
});
Sign up to request clarification or add additional context in comments.

Comments

1

Figured out the issue, simply set a variable to the value in column 1 [0] and then returned the value in the POST. var id2 = oTable.fnGetData( aPos2[0] );

Comments

0

I would try this

"submitdata": function ( value, settings ) {
    console.log(this);
    return {
        "row_id": this.parentNode.getAttribute('id'),
        "column": oTable.fnGetPosition( this )[2]
    };
},

And watch your console for the this object, it will show you everything that you have access to.

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.