Force to reload one row

Force to reload one row

walczakwalczak Posts: 4Questions: 2Answers: 0

hi,
I use a standalone editor like https://datatables.net/blog/2016-03-25 and https://datatables.net/blog/2019-01-11 in a subview in with a details-control button.

inside the editor on changing data this ist done:

     jQuery('.details-inline-input').on('click', function () {
         let triggerElement = jQuery(this);
         editor.inline(this, {
             onBlur: 'submit',
             onComplete: function () {
                 triggerReloadFromDetails(triggerElement, row)
             }
         });
     });

triggerReloadFromDetails reloads the Top Table and opens (handleDetailsControlButtonTrigger) once again the subview.

function triggerReloadFromDetails(triggerElement, row)
{
    let dt = jQuery("#pricesLandlordDeposits").DataTable();
    dt.ajax.reload(null, false);

    handleDetailsControlButtonTrigger(triggerElement, dt, function () {
        showRowDetails(row);
    }, true);
}

Because the changes in the editor subview changes only the data of one row. I think it should be enough to reload only this one row.
A workaround with forcing the one row to reload with top_editor.edit().submit() could work. Is this the right way?

This question has an accepted answers - jump to answer

Answers

  • walczakwalczak Posts: 4Questions: 2Answers: 0
    edited November 2019

    Solved it myself this way:

    function triggerReloadFromDetails(row, editor)
    {
        editor
            .edit( row, false, {
                submit: 'changed'
            } )
            .set( 'reloadtrigger', 'true' )
            .submit();
    }
    
  • allanallan Posts: 63,195Questions: 1Answers: 10,412 Site admin
    Answer ✓

    That's a nice way of utalising the code you've already got. The only other option really is to use row().data() to update the data with information you've got from the server with a custom Ajax call for that specific row.

    Allan

This discussion has been closed.