locked
lightswitch RRS feed

Answers

  • Monday, August 19, 2013 12:50 PM
  • If this is for the LightSwitch HTML Client see:

    Computed Properties With the LightSwitch HTML Client

    Because as of now computed properties created on the data layer will not show up in the HTML Client.

    Also see:

    HUY Volume III– Popups, Dirty Visual Collections, and Using Prototypes To Calculate Child Collections 

    for something that comes close:

    // Calculated field to count Available OrderDetails
    
    myapp.Order.prototype.getAvailable = function () {
    
        return this.OrderDetails.sum(function (item) {
    
            return item.ItemAvailable == true;
    
        });
    
    };
    
    
    // Calculated field to count UnAvailable OrderDetails
    
    myapp.Order.prototype.getUnAvailable = function () {
    
        return this.OrderDetails.sum(function (item) {
    
            return item.ItemAvailable == false;
    
        });
    
    };

    myapp.AddEditOrder.AvailableItems_postRender = function (element, contentItem) {
    
        // Get the Order on the screen
    
        var order = contentItem.screen.Order;
    
        // Show the current count
    
        element.innerText = order.getAvailable();
    
    
        // Method that will be called on update of count
    
        function updateValue() {
    
            element.innerText = order.getAvailable();
    
        }
    
    
        // Add event listener
    
        order.OrderDetails.addEventListener(
    
            "collectionchange", updateValue);
    
    
        // Trigger load of OrderDetails
    
        order.getOrderDetails();
    
    
        // Clean up event listener
    
        contentItem.handleViewDispose(function () {
    
            parent.Children.removeEventListener(
    
                "collectionchange", updateValue);
    
        });
    
    };
    
    
    myapp.AddEditOrder.UnAvailableItems_postRender = function (element, contentItem) {
    
        // Get the Order on the screen
    
        var order = contentItem.screen.Order;
    
        // Show the current count
    
        element.innerText = order.getUnAvailable();
    
    
        // Method that will be called on update of count
    
        function updateValue() {
    
            element.innerText = order.getUnAvailable();
    
        }
    
    
        // Add event listener
    
        order.OrderDetails.addEventListener(
    
            "collectionchange", updateValue);
    
    
        // Trigger load of OrderDetails
    
        order.getOrderDetails();
    
    
        // Clean up event listener
    
        contentItem.handleViewDispose(function () {
    
            parent.Children.removeEventListener(
    
                "collectionchange", updateValue);
    
        });
    
    };


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    Monday, August 19, 2013 1:12 PM

All replies

  • Hi,

    I am moving your thread into the Visual Studio LightSwitch - General Questions Forum for dedicated support. Thanks for your understanding.

    Best Regards,


    Jack Zhai[MSFT]
    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 19, 2013 12:00 PM
  • Monday, August 19, 2013 12:50 PM
  • If this is for the LightSwitch HTML Client see:

    Computed Properties With the LightSwitch HTML Client

    Because as of now computed properties created on the data layer will not show up in the HTML Client.

    Also see:

    HUY Volume III– Popups, Dirty Visual Collections, and Using Prototypes To Calculate Child Collections 

    for something that comes close:

    // Calculated field to count Available OrderDetails
    
    myapp.Order.prototype.getAvailable = function () {
    
        return this.OrderDetails.sum(function (item) {
    
            return item.ItemAvailable == true;
    
        });
    
    };
    
    
    // Calculated field to count UnAvailable OrderDetails
    
    myapp.Order.prototype.getUnAvailable = function () {
    
        return this.OrderDetails.sum(function (item) {
    
            return item.ItemAvailable == false;
    
        });
    
    };

    myapp.AddEditOrder.AvailableItems_postRender = function (element, contentItem) {
    
        // Get the Order on the screen
    
        var order = contentItem.screen.Order;
    
        // Show the current count
    
        element.innerText = order.getAvailable();
    
    
        // Method that will be called on update of count
    
        function updateValue() {
    
            element.innerText = order.getAvailable();
    
        }
    
    
        // Add event listener
    
        order.OrderDetails.addEventListener(
    
            "collectionchange", updateValue);
    
    
        // Trigger load of OrderDetails
    
        order.getOrderDetails();
    
    
        // Clean up event listener
    
        contentItem.handleViewDispose(function () {
    
            parent.Children.removeEventListener(
    
                "collectionchange", updateValue);
    
        });
    
    };
    
    
    myapp.AddEditOrder.UnAvailableItems_postRender = function (element, contentItem) {
    
        // Get the Order on the screen
    
        var order = contentItem.screen.Order;
    
        // Show the current count
    
        element.innerText = order.getUnAvailable();
    
    
        // Method that will be called on update of count
    
        function updateValue() {
    
            element.innerText = order.getUnAvailable();
    
        }
    
    
        // Add event listener
    
        order.OrderDetails.addEventListener(
    
            "collectionchange", updateValue);
    
    
        // Trigger load of OrderDetails
    
        order.getOrderDetails();
    
    
        // Clean up event listener
    
        contentItem.handleViewDispose(function () {
    
            parent.Children.removeEventListener(
    
                "collectionchange", updateValue);
    
        });
    
    };


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    Monday, August 19, 2013 1:12 PM