locked
LS HTML Client - Screen dialogue behavior RRS feed

  • Question

  • I want to create a screen and use it as a dialogue (that way I can reuse it instead of creating the same popup in multiple screens). How do I wire the selection in the dialogue screen to the item in the caller screen. Similar to this article but instead of using a popup I want a reusable dialogue screen. Thanks in advance.
    • Edited by JCMonto Sunday, June 2, 2013 2:48 PM
    Sunday, June 2, 2013 4:26 AM

Answers

  • Michael

    I got it to work. You got me thinking about the entity on the screen. So what I did is: I added a local property of type School to the screen and renamed the items Collection as SchoolList . Then in the Tap event of the SchoolList items, I added the code below. 

    myapp.SchoolsFilter.SchoolList_ItemTap_execute = function (screen) {
        //Write code here.
        screen.School = screen.SchoolList.selectedItem;
     };

    After this I was able to access the School local property of the screen and use it in the caller screen.

    Thanks for your help.

    • Marked as answer by JCMonto Monday, June 3, 2013 3:34 AM
    Monday, June 3, 2013 3:34 AM

All replies

  • Update...

    I tried the code below:

    myapp.UserEdit.SelectSchool_Tap_execute = function (screen) {
    
        myapp.showSchoolsFilter(screen.User, {
    
            afterClosed: function (schoolsFilterScreen, navigationAction) {
                screen.User.School = schoolsFilterScreen.Schools.selectedItem;
            }
        });
    };
    I am calling a dialogue screen from an User Edit Screen. My idea is to allow the user to select a school from another screen dialogue. And return the selected school to update the User.School of the parent or caller window. I am following this forum entry . But for some reason the afterclosed event never gets fired.  Please advise. Thanks.
    Sunday, June 2, 2013 7:55 PM
  • Use intellisens to check the proper signature of the method:

    myapp.showSchoolsFilter(

    For example if it is a Browse screen it may not have a parameter so it could be:

        myapp.showSchoolsFilter({
    
            afterClosed: function (schoolsFilterScreen, navigationAction) {
                screen.User.School = schoolsFilterScreen.Schools.selectedItem;
            }
        });


    The Visual Studio LightSwitch Marketplace

    http://LightSwitchHelpWebsite.com


    Sunday, June 2, 2013 11:41 PM
  • Michael

    You were correct I changed my code and now the afterClosed event is fired:

    myapp.UserEdit.SelectSchool_Tap_execute = function (screen) {
        myapp.showSchoolsFilter({
    
            beforeShown: function (schoolsFilterScreen) {
    
            },
    
            afterClosed: function (schoolsFilterScreen, navigationAction) {
                var selectedSchool = schoolsFilterScreen.Schools.selectedItem;
                screen.User.School = selectedSchool;
            }
        });
    };

    However, in  debug mode I can see schoolsFilterScreen but I can not get access to the schools collection to get the selected item.

    schoolsFilterScreen.Schools is returning undefined.

    Of course the screen has a collection of schools and it has a selected item. But I can not find it in the tree structure of the returned schoolsFilterScreen . Any ideas?

    Monday, June 3, 2013 1:13 AM
  • Are you sure it is spelled "Schools" on the screen? Case matters. Can you post a screen shot?

    Normally when you have an entity on the screen, it is a parameter that you can pass when opening the screen.


    The Visual Studio LightSwitch Marketplace

    http://LightSwitchHelpWebsite.com

    Monday, June 3, 2013 1:32 AM
  • Yes the name is correct. This screen should return the selected item and pass it back to the caller screen.

    I am getting the screen object back but I can not access the Schools.selectedItem

    Monday, June 3, 2013 3:02 AM
  • Oh orginally you said "schoolsFilterScreen.Schools is returning undefined". If you are getting School back then that means that the .selectItem is not being set. Usually because no one clicked on it to make a selection? 

    The Visual Studio LightSwitch Marketplace

    http://LightSwitchHelpWebsite.com

    Monday, June 3, 2013 3:16 AM
  • Michael

    I got it to work. You got me thinking about the entity on the screen. So what I did is: I added a local property of type School to the screen and renamed the items Collection as SchoolList . Then in the Tap event of the SchoolList items, I added the code below. 

    myapp.SchoolsFilter.SchoolList_ItemTap_execute = function (screen) {
        //Write code here.
        screen.School = screen.SchoolList.selectedItem;
     };

    After this I was able to access the School local property of the screen and use it in the caller screen.

    Thanks for your help.

    • Marked as answer by JCMonto Monday, June 3, 2013 3:34 AM
    Monday, June 3, 2013 3:34 AM