Search code examples
visual-studio-lightswitchlightswitch-2013

Dynamically updating after save (Lightswitch HTML)


Basically I have an ordering System which consists of a ViewOrderScreen and AddPartScreen screen.

the ViewOrderScreen contains a table view which displays all the parts that have been added. It also displays a Total field which is referenced from the tblOrders.

Now what I want to achieve is this: when I add a part, a Dialog window opens up, I select the part, add the quantity, then hit save. The dialog box then disappears and the part is displayed in the table view. However the Total field is not updated until I refresh the page.

So my question, how can I get this value to update everytime I add a part?

I am using a data item (Money) called Display which currently displays this value... thanks for any help


Solution

  • This works a treat, but my main problem was the Total field not being updated on the JavaScript code. i did all the calculation in C# but this was updating the data at thw wrong time

    setInterval(function() {
    
        var a = parseFloat(contentItem.screen.OrderRequest.Total);
        var b = parseFloat(contentItem.screen.OrderRequest.CarriageCost);
    
    
        contentItem.dataBind("value", function(newValue) {
            var c = a + b;
    
    
            element.innerText = "£" + c;
        });
    },500);