locked
LightSwitch 2013 HTML Client - Custom AddEdit save button cannot close dialog screen before navigating to another screen .... RRS feed

  • Question

  • Hi, 

    firstly, I love the benefits of LS HTML Client, and,  I am just learning light switch HTML Client.

    I am trying to have two buttons on my page, one that will save this AddEdit data and then navigate back to the menu (that one is easy and done). The second button will save this AddEdit data, BUT, I need it to CLOSE the current AddDetail screen and navigate to a detail browse screen that displays the detail and will allow the user to add detail data from there. Closing the AddEdit from my custom save button BEFORE I NAVIGATE TO MY FULL BROWSE SCREEN is my problem.

    After trying some things, I am wondering if I am coming to some correct conclusions?

    It seems like the AddEdit screen can only be closed by the LS methods NavigateHome & back or commitChanges, cancelChanges.  These automatically do their job, close the screen and return to the previous screen.  Even WITHOUT the afterClosed being defined, the  AddEdit screens automatically generate the LS standard “Save” and “Discard” buttons. Even WITHOUT the afterClosed process being defined, the LS standard “Save” and “Discard” buttons will also automatically close the modal dialog. 

    A custom save button can automatically close a modal dialog AddEdit screen IF it calls “navigateHome”, “navigateBack”, “commitChanges” or “cancelChanges”. But these functions will automatically navigate to the previous screen (except “navigateHome” ).

    Without using these 4 functions, custom save buttons can navigate to other screens, but the screens a custom button navigates to will just appear within the AddEdit modal dialog AREA (so navigating to full screen will only show it partially displayed within that AREA), and  THERE IS NO CLOSE() functions you use with a custom save button to close the AddEdit modal dialog  screen BEFORE navigating to another screen. 

    Also, custom save buttons do not trigger the afterClose process simply because it is CUSTOM and not an LS generated button like the LS standard “Save” and “Discard” buttons.

    You CANNOT use afterClosed thinking that it will respond to a custom button because custom buttons are not wired to afterClosed processing.  

    Using beforeShown and afterClosed is to take advantage of LS common save and discard processing (and only work with the LS save and discard generated buttons).

    Now, if the above is true, then I need LS to give me a close() function so that I can use a custom save button to close the modal dialog and then display another screen.

    If I cannot, then I wish MS would include a more clearly defined explanation of their button navigation concepts and design in their API in a form that allows me to know the limitations of my "custom save buttons" in the AddEdit screen  and other scenarios.

    But mostly, I would like MS and LS to give me a standard "closeAddEditModalDialog()" function that will CLOSE the current AddEdit screen so that I can navigate to the next screen of my choosing. otherwise, using a custom save button from an AddEdit screen is very (and unnecessarily) limiting to the many ways.  I need to help my users have a more fluid navigation process to what data comes next.

    Or maybe I am just not seeing how to use a custom save button to close an AddEdit screen and navigate to another screen?

    Or I guess I have to just work in the confines of displaying my AddEdit screen with beforeShow and afterClosed, and ONLY use the standard "Save" and "Discard" buttons. Mind you, if this is because LS needs to  guide there apps down these specific "LS button "  navigation paths, I can work with that. but it can be limiting.

    Love LS HTML Client, so like they say "just saying" ......

    If there is anyone who can point me in the right direction, please do and thanks!


    david






    • Edited by iqworks Monday, November 3, 2014 11:35 AM
    Monday, November 3, 2014 11:25 AM

Answers

  • Hi david,

    Welcome to Lightswitch forum.

    From your description above, I'd like to suggest you to use the tips below to apply changes before you close the screen.

    • myapp.applyChanges(): Calling apply will save all the changes of the current changeset. If only one changeset exists, it will save them to the database. If the current changeset is a nested scope, it will commit the changes to the parent changeset.
    • myapp.commitChanges(): Calling commit will save all the changes of the current changeset, just like applyChanges. Afterwards the application will navigate back to the previous screen.
    • myapp.cancelChanges(): Cancel will undo all changes in the current changeset and navigate back to the previous screen. Again, you do not need to worry about nested changesets, we will do that for you.

     The following code snippet shows you how to implement a delete command.

    myapp.ViewCustomer.Delete_execute = function (screen) {    
        screen.Customer.deleteEntity();
        return myapp.commitChanges().then(null, function fail(e) {
            myapp.cancelChanges();
            throw e;
        });
    };

    Please let me know if there is anything that I can do to help.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Angie Xu Monday, November 17, 2014 5:45 AM
    Tuesday, November 4, 2014 9:27 AM
  •  It just seems like I need a close() api, or some way of telling

    commit and cancel NOT to navigate to the previous page?

    Hi David,

    Thanks for your feedback.

    For this issue, I'd also like to share one LightSwitch blog to you, it has simplified API explained. See: A New User Experience (Heinrich Wendel)

    Hope it helps you.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Angie Xu Monday, November 17, 2014 5:45 AM
    Monday, November 10, 2014 9:02 AM

All replies

  • Hi david,

    Welcome to Lightswitch forum.

    From your description above, I'd like to suggest you to use the tips below to apply changes before you close the screen.

    • myapp.applyChanges(): Calling apply will save all the changes of the current changeset. If only one changeset exists, it will save them to the database. If the current changeset is a nested scope, it will commit the changes to the parent changeset.
    • myapp.commitChanges(): Calling commit will save all the changes of the current changeset, just like applyChanges. Afterwards the application will navigate back to the previous screen.
    • myapp.cancelChanges(): Cancel will undo all changes in the current changeset and navigate back to the previous screen. Again, you do not need to worry about nested changesets, we will do that for you.

     The following code snippet shows you how to implement a delete command.

    myapp.ViewCustomer.Delete_execute = function (screen) {    
        screen.Customer.deleteEntity();
        return myapp.commitChanges().then(null, function fail(e) {
            myapp.cancelChanges();
            throw e;
        });
    };

    Please let me know if there is anything that I can do to help.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Angie Xu Monday, November 17, 2014 5:45 AM
    Tuesday, November 4, 2014 9:27 AM
  • Thanks Angie,

          Thank you for confirming my understanding of how these navigation buttons work. I am doing this testing in my development environment on my laptop using FF and IE. So maybe this behavior is different on a mobile device.

          The problem is that my add/edit dialog screen will not CLOSE when I use applyChanges() and then myapp.showNextScreen(). It will show this NextScreen WITHIN the add/edit dialog screen. This NextScreen is a full screen (at least in IE and FF in my dev environment), but only partially displays when it is in this dialog screen.
           If I use commitChanges(), the dialog screen will close but the previous screen will momentarily display BEFORE the myapp.showNextScreen() displays the NextScreen.
            If I use cancelChanges(), the dialog screen will close but the previous screen will momentarily display BEFORE the myapp.showNextScreen() displays the NextScreen.

            Right now, I am using this code, as stated, the previous screen displays BEFORE the myapp.ShowNextScreen() performs its navigation.

    myapp.AddEditLogExercise.callMeasures_execute = function (screen) {
       // Write code here.   
             myapp.activeDataWorkspace.SQLDB.saveChanges().then(function () {
                 myapp.commitChanges().then(function () {//Briefly displays previous screen                
                    myapp.showViewEnterLogAandDetail2(screen.DailyLog, screen.ememberNo, screen.esecurityCode);
                });
            }); 
       };
    
     It just seems like I need a close() api, or some way of telling

    commit and cancel NOT to navigate to the previous page?

    thanks again for your time

     


    david

    Saturday, November 8, 2014 5:35 PM
  •  It just seems like I need a close() api, or some way of telling

    commit and cancel NOT to navigate to the previous page?

    Hi David,

    Thanks for your feedback.

    For this issue, I'd also like to share one LightSwitch blog to you, it has simplified API explained. See: A New User Experience (Heinrich Wendel)

    Hope it helps you.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Angie Xu Monday, November 17, 2014 5:45 AM
    Monday, November 10, 2014 9:02 AM
  • thanks Angie, I will read it.

    david

    Monday, November 24, 2014 5:11 PM