Multiple columns in MultipleValuesResourceControl

2 posts, 1 answers
  1. Jason
    Jason avatar
    13 posts
    Member since:
    Sep 2006

    Posted 01 Nov 2011 Link to this post

    I'm using several MultipleValueResourceControls in the AdvancedForm.  I would like to have the flexibility to set the number of columns in the CheckBoxList per MultipleValueResourceControl.  I have one instance of the control where there are only 2 selections and should appear in 1 column, but another with close to 40 that I would like to spread out over 4 columns. 

    Can someone please point me in the right direction?

    Thanks.
  2. Answer
    Peter
    Admin
    Peter avatar
    6637 posts

    Posted 03 Nov 2011 Link to this post

    Hi Jason,

    You can use the Advanced Templates demo and the related help topic. In code-behind of MultipleValuesResourceControl, you need to comment the override of the Render method of the SemanticCheckBoxList class and then you can set conditionally the RepeatColumns property:
      protected class SemanticCheckBoxList : CheckBoxList
        {
            //protected override void Render(HtmlTextWriter writer)
            //{
            //    writer.WriteBeginTag("ul");
     
            //    writer.WriteAttribute("class", "rsCheckBoxList");
     
            //    writer.Write(HtmlTextWriter.TagRightChar);
     
            //    for (int i = 0; i < RepeatedItemCount; i++)
            //    {
            //        writer.RenderBeginTag(HtmlTextWriterTag.Li);
            //        RenderItem(ListItemType.Item, i, null, writer);
            //        writer.RenderEndTag();
            //    }
     
            //    writer.WriteEndTag("ul");
            //}
        }
     
    //* * *
     
     protected void Page_Load(object sender, EventArgs e)
        {
            SemanticCheckBoxList resourceValue = new SemanticCheckBoxList();
            resourceValue.ID = "ResourceValue";      
            
            ResourceValuesPlaceHolder.Controls.Add(resourceValue);
     
            if (resourceValue.Items.Count == 0)
            {
                PopulateResources();
                MarkSelectedResources();
            }
     
           if (resourceValue.Items.Count > 3)
            {
                resourceValue.RepeatColumns = 2;
            }
            if (resourceValue.Items.Count > 6)
            {
                resourceValue.RepeatColumns = 3;
            }
            if (resourceValue.Items.Count > 9)
            {
                resourceValue.RepeatColumns = 4;
            }
           
        }

    Also, add the following css fix to your RadScheduler page.
    div.RadScheduler .rsAdvancedEdit .rsResourceControls input
           {
               width: auto;
               vertical-align:middle;
           }
           .rsAdvancedEdit label
           {
              text-align:left !important;
              padding-left: 10px !important;
           }
           .rsResourceControls table
           {
               padding-left: 30px !important;
           }
     

    Attached is a sample for reference.

    All the best,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top