locked
HTML set visual collection selectedItem in code, after Tile list is redrawn RRS feed

  • Question

  • Is there any event I can listen to in order to catch when a list control (Tile list) has been completely redrawn on the screen? (Not in first postrender)

    Sorry for long explanation, if needed:

    The Tile list (Categories), is used to filter a Table (Items) in a browse screen.
    When user taps on a Category I set a local property (CurrentCategory) bound to Items Table filter parameter.

    The Categories list is based on a PreProcessQuery cause it needs to be filtered by another local property (Supplier) which obviously is not present in Category entity but only in Category.Items children.
    When I set the Supplier filter my Categories Tile list is automatically refreshed (hidden and then displayed again).

    The filters are working very well, but:

    Let's say user choose 'Hardware' Category and Items table gets filtered.
    After that user changes the Supplier and Category list gets filtered, CurrentCategory is still the same.
    Assuming for sake of brevity that the chosen Supplier is a 'Hardware' one, I would like to reset the Categories.selectedItem to 'Hardware' so that the correct Category summary looks selected (light blue).

    Right now I catch Categories visual collection idle state after load but at that moment looks like the Tile list has not been redrawn yet.

    myapp.BrowseItemsScreen.Categories_postRender = function (element, contentItem) {
        contentItem.screen.Categories.addChangeListener("state", function () {
            if (contentItem.screen.Categories.state == msls.VisualCollection.State.idle) {
                if (contentItem.screen.CurrentCategory !== null && contentItem.screen.CurrentCategory !== undefined) {
    		//at this moment the Tile list is NOT VISIBLE (REDRAWN)
                    contentItem.screen.Categories.selectedItem = contentItem.screen.CurrentCategory;
                };
            };
        });
    };

    Thanks in advance for any suggestion.


    Marco

    Monday, March 10, 2014 2:53 PM

All replies

  • Hi,

    From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Jun Zh - MSFT Microsoft Online Community Support

    Friday, March 14, 2014 8:00 AM
  • this is really beyond what we can do here in the forums.

    Could you please elaborate further on this? I can't understand.

    Does lightswitch is all about .NET+HTML+javascript technologies ?

    I'm asking about listening on an event, why this should be outside of the forum scope?

    I'll try to manage testing on my own and looking for informations elsewhere, as usual, and don't want to discuss microsoft decision to move HTML5 to the foreground cause I'm always ready to learn and indeed I like LS, but do you mean this is the right way to support .NET devs on their learning curve? are you sure ms is offering adequate documentation about LS (out of great personal blogs artichles) ?


    Marco

    Friday, March 14, 2014 8:50 AM
  • I still would like to know from moderators if it's legitimate to ask for this kind of question ih the forum, anyway I want to share my attempts for newbies like me...

    Browsing DOM elements state in debug I've found that checking for LI children count in Tile List could be an affordable and quite reliable solution.

    I've only one Tile list on my screen, therefore simply nesting the count check and selectedItem change inside a setTimeout seems to do the work:

    myapp.BrowseItemsScreen.Categories_postRender = function (element, contentItem) {
        contentItem.screen.Categories.addChangeListener("state", function () {
            if (contentItem.screen.Categories.state == msls.VisualCollection.State.idle) {
                if (contentItem.screen.CurrentCategory !== null && contentItem.screen.CurrentCategory !== undefined) {
                   setTimeout(function () {
                        if ($('.msls-tile-list').find('li').length > 0) {
                            contentItem.screen.Categories.selectedItem = contentItem.screen.CurrentCategory;
                        }
                    }, 300);
                };
            };
        });
    };

    I was wondering if could be more robust using setInterval/clearInterval until children count is >0.

    Any suggestons would be much appreciated.


    Marco

    Saturday, March 15, 2014 11:44 AM