none
Change list item style after edit (HTML client) RRS feed

  • Question

  • Hi there,

    We have a list of orders in a Browse screen. In the Layout postRender code we apply a css class based on the order quantity. All that works as expected. In the same screen, there is a button to edit an Order that shows a separate Edit screen.

    The issue is, how to update the class of the HTML element associated to the order that was edited when the Edit screen navigates back to the list of orders.

    Any help will be greatly appreciated!

    Thanks in advance,

    Rudy

    Wednesday, May 22, 2013 7:44 PM

Answers

  • I ended up doing the following in the postRender event of the list template:

    // update the cached order when one is selected
    $(element).on("click", function () {
       lastOrder = $(element);
    });

    This takes care of updating the cached item in the list when an edit takes place.

    Hope it helps someone else.

    Thank you Michael for taking the time to offer your suggestions.

    Thursday, May 23, 2013 1:04 PM
  • The article has been updated. Thank you!

    Visual Studio LightSwitch Screen Navigation and Advanced JavaScript Examples

    Updating an Existing Item

    A thank you to reader rnoda for providing code to handle updating the .css when editing an existing item.

    The first step is to add the following code to the postRender event of the List template:

       // Update the cached order when one is selected
        $(element).on("click", function () {
            // Cache the OrderDetail item so it can possibly be updated
            OrderDetailRowParent = $(element).parent();
        });

    Next, we create our own event that will be fired when the List control is clicked on.

    We use the following code for its method:

    myapp.AddEditOrder.DynamicEditOrderDetail_execute = function (screen) {
        // Open the AddEditOrderDetail screen 
        // Passing it the currently selected OrderDetails item
        myapp.showAddEditOrderDetail(screen.OrderDetails.selectedItem, {
            afterClosed: function (AddEditOrderDetailScreen, navigationAction) {
                // Update the last cached OrderDetailRowParent item 
                ColorOrderDetail(AddEditOrderDetailScreen.OrderDetail.OrderQuantity);
            }
        });
    };


    The Visual Studio LightSwitch Marketplace

    http://LightSwitchHelpWebsite.com

    Friday, May 24, 2013 1:56 PM

All replies