Update just one row

Update just one row

Samantha1999Samantha1999 Posts: 4Questions: 0Answers: 0

Hi, is there a method for updating just one row of a table when the data option is updated?

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Is this using Editor? I'm not too clear what you mean by "when the data option is updated" - please can you expand.

    Colin

  • rf1234rf1234 Posts: 2,958Questions: 87Answers: 418

    Just like Colin I am not 100% sure I understand your problem. I am assuming you have an ajax sourced table and you don't want to reload the entire table because of just one previous update.

    I have a similar situation: I want to avoid an ajax relad of my contract table and hence do a proprietary ajax call in order to retrieve certain cell values. On "success" I update table cells directly and also the data source of one particular field in order to make sure calculations done with this field are done properly. That was the most difficult thing for me: Understanding that updating a cell doesn't automatically mean that the data source Datatables / Editor uses to supply the field values is being updated as well.

    var selected = contractTable.row({selected: true});
    
    //avoid ajax reload of contract table for performance reasons
    //econ_end_date may have been affected by the last changes and the 
    //cashflow generation!
    $.ajax({
        type: "POST",
        url: 'actions.php?action=getFormatterMaxExpAndBeginDates',
        data: {
            contractId:    selected.data().contract.id 
        },
        dataType: "json",
        success: function (d) {
            contractTable.cell(selected, ".mED").data(d.maxExpDate).draw();
            contractTable.cell(selected, ".eeD").data(d.econ_end_date).draw();
            //update the data source of the hidden editor field calc_econ_end_date
            selected.data().contract.calc_econ_end_date = d.calc_econ_end_date;
        }
    });       
    

    Please see this as well:
    https://datatables.net/reference/api/cell().data()
    https://datatables.net/reference/api/draw()

Sign In or Register to comment.