locked
Extending Screens for Multi-Select in the LightSwitch HTML Client RRS feed

  • Question

  • Hi i read Mike Droney's article of 

    Extending Screens for Multi-Select in the LightSwitch HTML Client

    But i just want to understand the code, so what is the ‘__isSelected’ property? from where does it come?
    why does the contentItem.value.details have an ‘__isSelected’ property?

    is the value of the contentItem not the screen?

    and also how can i implement the ‘Can Execute Code’ only if one or more check boxes are checked?

    Thanks  

    • Edited by M. Lerner Monday, January 5, 2015 4:51 AM
    Monday, January 5, 2015 4:49 AM

Answers

All replies

  • But i just want to understand the code, so what is the ‘__isSelected’ property? from where does it come?

    why does the contentItem.value.details have an ‘__isSelected’ property?

    is the value of the contentItem not the screen?
    and also how can i implement the ‘Can Execute Code’ only if one or more check boxes are checked?
     

    The '__isSelected' property is a private member of the class msls.ContentItem related to the backing data for the selected item.  That is to say, it would be a private member if JavaScript actually had encapsulation and information hiding like a typical object-oriented language. I like to reference David Herman's description from his book Effective JavaScript:

    • Often, JavaScript programmers resort to coding conventions rather than any absolute enforcement mechanism for private properties. For example, some programmers use naming conventions such as prefixing or suffixing private property names with an underscore character (_). This does nothing to enforce information hiding, but it suggests to well-behaved users of an object that they should not inspect or modify the property so that the object can remain free to change its implementation.

    ...which means that it's generally not recommended to directly get or set backing data properties like __isSelected, instead working with the public property 'selectedItem', although it may work fine in certain cases like this one.

    To make _canExecute fire only when an item in the list is selected to enable a button method, try:

    return (screen.Contacts.selectedItem !== null);


    Monday, January 5, 2015 6:50 AM
  • Hi LittleBobbyTables

    Thanks for your reply

    But what is the backing data for the selected item, The screen or the item of the collection?

    And also the code for _canExecute is not good because its enabled even if all check boxes or unchecked!

    Thanks



    • Edited by M. Lerner Monday, January 5, 2015 4:51 PM
    Monday, January 5, 2015 4:25 PM
    • Marked as answer by Angie Xu Monday, January 19, 2015 1:35 AM
    Wednesday, January 7, 2015 7:10 AM