Run a function on refresh of Data Table

Sorry it is a List Control.
I am trying to calculate the sum of a field and then update fields in the form, this is what calculateStuff function does:

function calculateStuff(){
    var productLineItems = fd.control('ProductLineItems').widget.dataItems();
    var [totalCostToLucidica,totalCostToClient,orderProfit,margin,productTime,productNetRate] = [0,0,0,0,0,100];
    //Calculate Product Profitablity
    if (productLineItems.length > 0){
        totalCostToClient = parseFloat((productLineItems[0]['TotalCosttoClient.SUM']).replace('£',''));
        totalCostToLucidica = parseFloat((productLineItems[0]['TotalCosttoLucidica.SUM']).replace('£',''));
        orderProfit = totalCostToClient - totalCostToLucidica;
        if (totalCostToClient != 0 || totalCostToClient != null){
            margin = orderProfit * 100 / totalCostToClient;
        } 
    }
    
    //Calculate Product NetRate
    var productTimeItems = fd.control('TimeLog').widget.dataItems();
    if (productTimeItems.length > 0){
        productTime = parseFloat(productTimeItems[0]['Time.SUM']) / 60;
        if (productTime != 0 || productTime != null){
            productNetRate = orderProfit / productTime;
        } 
    }
    //Update Fields
    updateFieldTitles(productNetRate,margin);
    disableFields(false);
    fd.field('Supplier_x0020_Invoice_x0020_Tot').value = totalCostToLucidica;
    fd.field('Lucidica_x0020_Invoice_x0020_Tot').value = totalCostToClient;
    fd.field('Order_x0020_Overall_x0020_Profit').value = orderProfit;
    fd.field('Margin').value = margin;
    fd.field('Product_x0020_Time').value = productTime;
    fd.field('Product_x0020_NRBPBH').value = productNetRate;
    setTimeout(function(){disableFields(true);},10);
}

I just need to trigger it when the table is refreshed manually as we have the helpdesk plugin so all List controls have a refresh button hard coded in:
image