locked
What is options && options.groupKey ? Data.resolveItemReference(options.groupKey)

    Question

  • Can someone explain in lay terms what exactly "options && options.groupKey" does? I know && means "and" but don't understand how this first part of the code gets the group index? Not sure how to use the three "this._" variables to get the actual data displaying on the screen so I can use it for a number of purposes. Trying to specifically grab the blog title, post title and author. I see it in a sample split.js app as follows:

    ready: function (element, options) {
                var listView = element.querySelector(".itemlist").winControl;
    
                // Store information about the group and selection that this page will
                // display.
                this._group = (options && options.groupKey) ? Data.resolveGroupReference(options.groupKey) : Data.groups.getAt(0);
                this._items = Data.getItemsFromGroup(this._group);
                this._itemSelectionIndex = (options && "selectedIndex" in options) ? options.selectedIndex : -1;

    Tuesday, February 05, 2013 5:45 AM

Answers

  • Hi hoWiWeb,

    Q: what exactly "options && options.groupKey" does?

    && makes sure that the options object exists before getting the groupKey value on it. the parameter options in IPageControlMembers.ready method is an object that contains one or more property/value pairs to apply to the PageControl.  http://msdn.microsoft.com/en-us/library/windows/apps/hh770590.aspx

    Q: don't understand how this first part of the code gets the group index?

    in items.js you can find code below, which assign groupKey value for the page control
    var groupKey = Data.groups.getAt(args.detail.itemIndex).key;
    WinJS.Navigation.navigate("/pages/split/split.html", { groupKey: groupKey });

    Q: Not sure how to use the three "this._" variables to get the actual data displaying on the screen.
    in page control, you can use "this._" variables to reference the object/method that has defined in page control.

    To help you better understand that, I recommend you read how to create a page control here

    http://msdn.microsoft.com/en-us/library/windows/apps/hh770117.aspx

    Hope this helps, thanks.

     


    Yanping Wang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, February 06, 2013 7:36 AM
    Moderator