locked
Setting element properties not working on html page RRS feed

  • Question

  • Hi,

    I am trying to enable/disable buttons based on user permissions on load of an html page. The html page only has buttons on it that load "Browse*" pages and serves as the main page of my application. I have been trying to set the isvisible property to false for the button but it seems to ignore / fail on it without saying anything. here is the code:

    myapp.HomeScreen.ShowBrowseBusinesses_postRender = function (element, contentItem) {
        // Write code here.
        window.alert("sometext");
    
        myapp.HomeScreen.findContentItem("ShowBrowseBusinesses").isvisible = false; 
        
        window.alert("Done");
    };

    When I run the form, the first alert (Sometext) shows up, but the second alert never shows up, and if I remove the middle statement then the second alert appears.

    This tells me that my middle statement is failing somehow, but I don't see any errors.

    I have also tried the _created method for the page, with same result.

    Any help/tips would be appreciated

    Sunday, May 11, 2014 10:48 PM

Answers

  • Either of these work in VS2012

    myapp.HomeScreen.ShowBrowseBusinesses_postRender = function (element, contentItem) {
        contentItem.screen.findContentItem("ShowBrowseBusinesses").isVisible = false;
    };
    myapp.HomeScreen.created = function (screen) {
        screen.findContentItem("ShowBrowseBusinesses").isVisible = false;
    };

    The case of letters is very important. You should also take note of intellisense hints.

    For this you should use 'created' event for initial hide/show. Other events can do the same manipulation of the content tree for implementing business rules.

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Marked as answer by Angie Xu Tuesday, May 20, 2014 1:14 AM
    Tuesday, May 13, 2014 8:13 AM

All replies

  • screen.findContentItem("ShowBrowseBusinesses").isVisible = false;

    Monday, May 12, 2014 5:10 AM
  • Thanks for the response, however, I still have the same behavior.

    I.e. the first alert message is shown, the button is still visible, and the second message is never shown.

    I tried proper capitalization for the whole line, but still not working as expected. no errors.

    Running it in both IE and chrome has the same effect.

    This is VS lightswitch 2012.

    Any ideas?

    Monday, May 12, 2014 9:13 PM
  • Either of these work in VS2012

    myapp.HomeScreen.ShowBrowseBusinesses_postRender = function (element, contentItem) {
        contentItem.screen.findContentItem("ShowBrowseBusinesses").isVisible = false;
    };
    myapp.HomeScreen.created = function (screen) {
        screen.findContentItem("ShowBrowseBusinesses").isVisible = false;
    };

    The case of letters is very important. You should also take note of intellisense hints.

    For this you should use 'created' event for initial hide/show. Other events can do the same manipulation of the content tree for implementing business rules.

    Dave


    Dave Baker | AIDE for LightSwitch | Xpert360 blog | twitter : @xpert360 | Xpert360 website | Opinions are my own. For better forums, remember to mark posts as helpful/answer.

    • Marked as answer by Angie Xu Tuesday, May 20, 2014 1:14 AM
    Tuesday, May 13, 2014 8:13 AM