locked
Html Client :Merging programmatically an item in a visual collection RRS feed

  • Question

  • I have an html browse screen on customers and I make behind the scenes an odata post with a new customer. So, the customer is in the database but not on the screen. Obviously, I could do a screen refresh and then the new customer would be in the customer visual collection (and thus, on screen)

    But I don't want to use a refresh and want  to merge this new customer into the customers visual collection (but with the right entity state (unchanged, because it's already in the db).

    Any idea?


    paul van bladel

    Saturday, February 15, 2014 1:52 PM

Answers

All replies

  • If you want the visuals in the screen to change (the added Customer to show up in the list), why do you not want to do a refresh?


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com

    Saturday, February 15, 2014 8:49 PM
  • because I want to do it "silently".

    paul van bladel

    Sunday, February 16, 2014 7:36 AM
  • Calling this on just the collection should refresh the collection without refreshing the entire screen:

    New API For Refreshing Data in LightSwitch in Visual Studio 2013


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com

    Sunday, February 16, 2014 1:36 PM
  • The problem with just refreshing the visual collection is that it is still not as "silent" as one would like it to be. It still causes quite a flicker of the visual collection bound data table or list which is not a great user experience if it happens automatically.

    Reflecting the most up to date data on screen is a very common requirement. Meteor.js seems to have recognized this fundamental requirement and have solved it quite elegantly by abstracting it away from the developer. That is, it will always show the latest data for you, even it that relies on CouchDb functionality.

    I'm hoping that LS will evolve to take this kind of fundamental requirement into account so that we don't all have to write custom code to always refresh data using timers and/or signalr. SQL server does provide change notification mechanisms at the table level to do this, although I would like it to work for views as well, but that might require SQL server enhancements from what I can tell. 


    Regards, Xander. My Blog

    Sunday, February 16, 2014 9:03 PM
  • The problem with just refreshing the visual collection is that it is still not as "silent" as one would like it to be. It still causes quite a flicker of the visual collection bound data table or list which is not a great user experience if it happens automatically.


    Regards, Xander. My Blog

    Perhaps this will help:

    Dynamically Creating Records In The LightSwitch HTML Client

    // Add a new Customer
        var newCustomer = new myapp.Customer();
        newCustomer.CustomerName = "New";
        newCustomer.CustomerAge = 0;
    
    // Save all changes on the screen
        return myapp.activeDataWorkspace.ApplicationData
            .saveChanges().then(function () {
                alert('saved')
            });


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    • Edited by ADefwebserver Sunday, February 16, 2014 9:43 PM
    • Marked as answer by Angie Xu Monday, February 24, 2014 1:39 AM
    Sunday, February 16, 2014 9:43 PM