Adding two numbers in lightswitch 2013

64 Views Asked by At

I used this code for adding two numbers

    //contentItem.dataBind("screen.Table1Item.Value1", function (newValue) {
    //    contentItem.screen.Property1 =(contentItem.screen.Table1Item.Value1);
    //});
    //contentItem.dataBind("screen.Table1Item.Value2", function (newValue) {
    //    contentItem.screen.Property1 = (contentItem.screen.Table1Item.Value2);
    //});
    //contentItem.dataBind("screen.Table1Item.Property1", function (newValue) {
    //    contentItem.screen.Property1 = (contentItem.screen.Table1Item.Value1) + (contentItem.screen.Table1Item.Value2);
//});

Instead of adding the numbers it is appending.Is there anyone who can help me to figure out this issue?

1

There are 1 best solutions below

0
On

this works:

myapp.ViewTable1Item.Property1_postRender = function (element, contentItem) {

    function updateTotalAmount() {
        element.innerText =
            contentItem.screen.Table1Item.value1 +
            contentItem.screen.Table1Item.value2;
    }

    contentItem.dataBind("screen.Table1Item.value1", updateTotalAmount);
    contentItem.dataBind("screen.Table1Item.value2", updateTotalAmount);

};

both value1 and value2 are set as integers in the table. Property1 is a data item set as an integer

enter image description here