How to update the cell in a row using the custom textbox also in the same row

How to update the cell in a row using the custom textbox also in the same row

paulfelco0paulfelco0 Posts: 1Questions: 1Answers: 0

Hi! I just wanted to ask something regarding inline editing of datatable but first let me explain what i did.

This is how I declare my datatable.

tbl_item_list = 
$('#tbl_item_list').DataTable({
    'destroy'       : true,
    'paging'        : true,
    'lengthChange'  : false,
    'pageLength'    : 50,
    'ordering'      : true,
    'info'          : true,
    'autoWidth'     : true,
    'select'        : true,
    'sDom'          : 'tp<"clear">', 
    'aoColumnDefs': [
        { targets: [0],width: "10px"},
        {"className": "dt-center", "targets": [1,2,3,4,5,6,7,8]},
        {"className": "custom-center", "targets": 0}       
    ],
    "fnCreatedRow": function( nRow, aData, iDataIndex ) {
        $('td:eq(0)', nRow).append('<button id="remove_row" name="remove_row" type="submit" class="btn btn-default btn-xs"><i class="fa fa-trash"></i></button>');
        $('td:eq(6)', nRow).append('<input type="text" class="form-control cust-label cust-textbox dt-textbox" id="txt-qty" name="txt-qty" onkeypress="return validateFloatKeyPress(this,event);">');
        $('td:eq(7)', nRow).append('<input type="text" class="form-control cust-label cust-textbox dt-textbox" id="txt-disc" name="txt-disc" onkeypress="return validateFloatKeyPress(this,event);">');
    },
    'fnRowCallback' : function( nRow, aData, iDisplayIndex ) {
        $('td', nRow).attr('nowrap','nowrap');
        return nRow;
    }
}).on('user-select', function (e, dt, type, cell, originalEvent) {
    if ($(cell.node()).parent().hasClass('selected')) {
        e.preventDefault();
    }
});

As you can see on fnCreatedRow i add some elements which means when I add a new row a 2 textbox and a button it will show that elements.

Now here is my question. How can I update the last cell of the row while im typing on the textbox?

Thanks

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Is this using Editor?

    If not, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.