none
Screen auto refresh in HTML client RRS feed

  • Question

  • Hi Experts,

    I have browse screen which is binded to one of query which has filter paramters isApproved=False

    So on this screen I get list of all unapproved orders.

    When user select the  item in the screen he goes in the edit mode where he can approved the order (basically setting up IsApproved field to true).

    Now after the record is updated it navigates back to browse screen but I am still seeing the same old unapproved order, though it is already approved.

    I want to know how can i force  refresh the browse screen after the record is  updated.

    Thanks

    Goldy

    Wednesday, May 15, 2013 7:21 AM

Answers

  • Hi Goldy,

    You will have to write some custom code to handle the refresh of the visual collection. On your browse screen, instead of binding the List View Item Tap to editSelected, pick 'Write my own method'. Then you can write handle the afterClosed event to refresh your list.

    myapp.BrowseProducts.Product_ItemTap_execute = function (screen) {
        myapp.showAddEditProduct(screen.Products.selectedItem, {
            afterClosed: function () {
                screen.Products.load();
            }
        });
    };

    Replace the Italic parts with your screens and collection names.

    Best regards,
    Huy

    Friday, May 17, 2013 9:11 PM

All replies


  • Efficiently read and post to forums with newsreaders: http://communitybridge.codeplex.com
    Wednesday, May 15, 2013 10:02 PM
  • Hi David,

    I tried to call the load method on the created event on the screen

    myapp.ApproveOrders.created = function (screen) {
        // Write code here.
        screen.UnApprovedOrders.load();
    };

    But it didn't help. Any more suggestions ?

    Thursday, May 16, 2013 6:02 AM
  • I think the ‘created’ function is only called once at the beginning, not after the edit. 
     
    Did you check the link referenced by Huy?  This link discusses calling load() when a Refresh button is manually clicked, or after the edit in myapp.onSaveChanges:  http://social.msdn.microsoft.com/Forums/en-US/lightswitchhtml/thread/786d9d6f-ba7c-476c-b9ff-efb4f4b653c7
     
    I just re-read it and it is a bit confusing.  There were a couple problems trying to be solved:  1) prevent server from changing the entity on save and getting an error message ; 2) Getting results of editing Details to persist when Browse screen was navigated back to.  #2 was what ‘Evolex’ and you are concerned about.
     
    Thanks,
    David
     

    Efficiently read and post to forums with newsreaders: http://communitybridge.codeplex.com
    Thursday, May 16, 2013 10:27 AM
  • Hi Goldy,

    You will have to write some custom code to handle the refresh of the visual collection. On your browse screen, instead of binding the List View Item Tap to editSelected, pick 'Write my own method'. Then you can write handle the afterClosed event to refresh your list.

    myapp.BrowseProducts.Product_ItemTap_execute = function (screen) {
        myapp.showAddEditProduct(screen.Products.selectedItem, {
            afterClosed: function () {
                screen.Products.load();
            }
        });
    };

    Replace the Italic parts with your screens and collection names.

    Best regards,
    Huy

    Friday, May 17, 2013 9:11 PM
  • Thanks Huy

    Without you my this lightswitch project would not have been possible.

    Whatever I have learned from you , I have put it in a blog post.

    http://goldytech.wordpress.com/2013/06/01/lessons-learned-with-lightswitch-html-client-project/

    Regards

    Goldy

    • Edited by goldytech Monday, June 3, 2013 7:22 AM added blog post link
    Monday, May 20, 2013 7:51 AM
  • I have this same issue.  However my parent screen ("Products") is a view.  When I go in the debugger and set a breakpoint "Products" is not visible.  I get a null pointer error.

    e.g.

    below vwProducts does not show in debugger.

    myapp.BrowseProducts.Product_ItemTap_execute = function (screen) {
        myapp
    .showAddEditProduct(screen.vwProducts.selectedItem, {
            afterClosed
    : function () {
                screen
    .vwProducts.load();
           
    }
       
    });
    };

    Monday, June 3, 2013 2:32 PM
  • Hi,

    In general, you can open your screen designer and find the Visual Collection name that you should use. For example in the case below, the call to load should be screen.Customers.load()

    In the code snippet above, is myapp.BrowseProducts.Product_ItemTap_execute = function (screen) { generated for you by LightSwitch, or you're just copying my sample code? If the code is generated for you by LightSwitch, most likely your collection name is Products, not vwProducts.

    Best regards,
    Huy

    Tuesday, June 4, 2013 9:44 PM
  • All the parameters look correct in the debugger.  However I get the UnSaved changes screen popup and only when click saved does the showAddEditInterest screen popup. Again everything works properly if I don't write my own method.

    Tuesday, June 4, 2013 11:49 PM
  • Hi,

    You're getting the prompt because you created a new Interest in the Browse Advisors screen, then try to navigation to a different screen. What you should do instead is

    var vmAdvisor = screen.vmAdvisors.selectedItem.Advisor;
    var vmInterest = screen.vmAdvisors.selectedItem.Interest;
    
    myapp.showAddEditInterest(null, vmInterest, vmAdvisor, {
        beforeShown: function(editScreen) {
            var newInterest = new myapp.Interest();
            editScreen.Interest = newInterest;
        },
        afterClosed: function() {
            screen.vmAdvisors.load();
        }
    });

    You may need to replace the italic part with the correct property name on the screen.

    Best regards,
    Huy


    Wednesday, June 5, 2013 12:06 AM
  • The ShowAddEditInterest screen appears but I can't assign any values to the variables. 

    e.g.

    myapp.AddEditInterest.created = function (screen) {
        // Write code here.
        screen.TempAdvisor = screen.EditAdvisor;
        screen.TempInterest = screen.EditInterest;
    };

    Also the

    Interests_Inserting(Interest entity)  isn't called after clicking save button on the ShowAddEditInterest.

    Wednesday, June 5, 2013 1:08 AM
  • Hi,

    I made a typo above, it should be beforeShown, not beforeShow.

    Best regards,
    Huy

    • Proposed as answer by Kdraper Wednesday, June 5, 2013 1:44 PM
    Wednesday, June 5, 2013 1:19 AM
  • Thanks everything works as expected
    • Proposed as answer by Kdraper Monday, June 24, 2013 8:27 PM
    Wednesday, June 5, 2013 1:45 PM
  • Hi, for some reason this isn't working for me.

    here's my code

    myapp.BrowseAvailable.AvailableItems_ItemTap_execute = function (screen) {

        // Write code here.
        myapp.showEditAvailable(screen.BrowseAvailable.selectedItem, {
            afterClosed: function () {
                screen.BrowseAvailable.load();
            }
        });
    };


    Error message when tapping an item "Cannot read property 'selectedItem' of undefined.

    Please kindly advise. Many thanks


    Friday, June 14, 2013 7:46 PM
  • Hi,

    Notice the difference between screen name and screen property name. In your case the screen name is BrowseAvailable and the screen property name is AvailableItems, so your code should be

    myapp.BrowseAvailable.AvailableItems_ItemTap_execute = function (screen) {
    
         // Write code here.
         myapp.showEditAvailable(screen.AvailableItems.selectedItem, {
             afterClosed: function () {
                 screen.AvailableItems.load();
             }
         });
     };
    

    Best regards,
    Huy
    • Proposed as answer by ADefwebserver Monday, June 24, 2013 8:21 PM
    Friday, June 14, 2013 10:36 PM
  • Hi, thanks for the reply. I've made some changes as suggested but still error the same. I'm not sure what i'm missing. I'm working on a screen name BrowseAvailable, with tab name AvailableItems, another tab name is ClosedItems. Any idea why i'm getting the error?

    Many Thanks

    John

     
    Friday, June 14, 2013 11:10 PM
  • Finally it's now working..

    You are right, there's a difference in the screen name, almost forgot it's case sensitive. :)

    Again, Many thanks for your help.

    Regards,

    John

    Friday, June 14, 2013 11:26 PM