Wednesday, December 26, 2012

Function to gen linkbar items

I was tinkering with a linkbar the other day and wanted to share some tidbits I found useful.  I wanted to dynamically load it so I set up a server script to pull a list of items for me to populate.  Since I had multiple groups to add, I created two functions to load them, one for the groups, the other for the items:

//region LINKBAR FUNCTIONS
function CreateGroup(Grptext)
{
    //Creates a group item for a Link Bar
    //add a variable for the commandbargroup if this is desired to be multifunctional
    if (Grptext!= null)
        {
            var bargrp : CommandBarGroup = lnkIntake.CreateNewGroup();
            bargrp.Text = Grptext;
            lnkIntake.Groups.Add(bargrp);
            return bargrp;       
   
        }

}

function CreateGroupItem(bar : CommandBarGroup, Itemtext, Itemvalue)
{
    //Creates a group item for the Link Bar
    //add a variable for the commandbargroup if this is desired to be multifunctional

    if (bar!= null)
        {
            var baritem : CommandBarItem = bar.CreateNewItem();
            baritem.Text = Itemtext;
            baritem.Value = Itemvalue;
            bar.Items.Add(baritem);
   
        }

}
//endregion LINKBAR FUNCTIONS

No comments:

Post a Comment