Panel Bar Background color and Hover problem

6 posts, 0 answers
  1. Dharmesh
    Dharmesh avatar
    3 posts
    Member since:
    Jul 2011

    Posted 28 Oct 2011 Link to this post

    Hi,

    1. I am trying to set back ground color for child item of panel bar but its not setting.
    2. How can i remove hover style for panel bar. I don't want hover style on Panel bar. 
    3. I want to see multiple items but once i click on different panel bar it collapse. so how can i see multiple items. I wrote following code still its not working.
    ExpandMode = PanelBarExpandMode.MultipleExpandedItems


    Ascs code


    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <telerik:RadCodeBlock ID="rcbCycleChangeHistoryCodeBlock" runat="server">
        <style type="text/css">
            .RadPanelBar_Windows7 .rpOut
            {
                background-color: #AC0000;               
                font-weight: bold;            
                font-family: Verdana,Helvetica,Calibri;
                font-size: 10px;
                color: #FFFFFF;       
                background-color:  #AC0000;       
            }
            
        </style>
    </telerik:RadCodeBlock>


    <telerik:RadAjaxPanel ID="rapCycleHistory" runat="server">
    </telerik:RadAjaxPanel>


    In code behind in page load


    RadPanelBar cycleChangeHistory = new RadPanelBar()
                {
                    AllowCollapseAllItems = true,
                    ID = "rpbCycleHistoriesItem",
                    RegisterWithScriptManager = true,
                    SkinID = "Windows7",
                    ViewStateMode = ViewStateMode.Inherit,
                    Width = Unit.Percentage(98),
                    CookieName = string.Format("CycleChangeHistory_{0}", base.JcnData.JcnListId),
                    PersistStateInCookie = true,
                    ExpandMode = PanelBarExpandMode.MultipleExpandedItems


                };
                cycleChangeHistory.ItemClick += new RadPanelBarEventHandler(rpbCycleItems_ItemClick);
                rapCycleHistory.Controls.Add(cycleChangeHistory);


                var changeSets = CycleChangesets.OrderByDescending(jcs => jcs.CycleChangeset);


                if (0 == cycleChangeHistory.Items.Count)
                {
                    short changeSetCount = 0;
                    IList<string> cycles = changeSets.Select(cs => cs.CycleNumber).ToList();
                    foreach (string cycle in cycles.Distinct())
                    {
                        RadPanelItem changeSetBlock = new RadPanelItem()
                        {
                            Text = string.Format("Cycle {0} ({1})", cycle, cycles.Where(c => c == cycle).Count()),
                            Expanded = false,
                            ClientIDMode = ClientIDMode.Inherit,
                            TabIndex = changeSetCount,
                            Value = string.Format("Cycle:{0}", cycle),
                            PostBack = true,
                            ChildGroupCssClass = "rpOut",
                        };


                        cycleChangeHistory.Items.Add(changeSetBlock);
                        changeSetCount += 1;
                    }
                }


     item click event.


            protected void rpbCycleItems_ItemClick(object sender, RadPanelBarEventArgs e)
            {
                RadPanelItem headerItem = e.Item;


                if (0 == headerItem.Controls.Count)
                {
                    if (0 < headerItem.Value.IndexOf("|"))
                    {
                        string[] valuePieces = headerItem.Value.Split('|');
                        string cycleNumber = valuePieces[0].Substring((valuePieces[0].IndexOf(":") + 1));
                        string cycle = valuePieces[0].Substring((valuePieces[0].IndexOf(":") + 1)).Trim().Substring(valuePieces[0].Substring((valuePieces[0].IndexOf(":") + 1)).Trim().Length - 3);
                        int changesetId = int.Parse(valuePieces[1].Substring((valuePieces[1].IndexOf(":") + 1)));
                        if (Session["CycleParameters"] != null)
                            cycleParameters = Session["CycleParameters"] as List<CycleParameter>;


                        CycleParameter cp = cycleParameters.Where(p => p.cycleNumber == cycle && p.cycleChangeset == changesetId).FirstOrDefault();
                        GetCycleChangeHistoryData(cp.jcnListId, cp.jcnChangeset, cp.cycleId, cp.cycleChangeset, cp.cycleNumber, cp.cycleChangesetCount);
                        CycleChangeHistoryInformation changeSet = CycleChangesets.Where(ccs => ccs.CycleNumber.Trim() == cycle.Trim() && ccs.CycleChangeset == changesetId).FirstOrDefault();
                        if (changeSet.Items == null)
                            changeSet.Items = new List<CycleChangesetDifferenceItem>();
                        if (changeSet.Comments == null)
                            changeSet.Comments = new List<CycleChangesetCommentItem>();
                        IList<string> sectionHeaders = changeSet.Items.OrderBy(o => o.orderByCycleSectionName).Select(rcd => rcd.SectionName).Distinct().ToList();


                        Table historyInformation = new Table()
                        {
                            CellPadding = 0,
                            CellSpacing = 5
                        };


                        int rowCount = 0;
                        foreach (string section in sectionHeaders)
                        {
                            var itemfound = changeSet.Items.Where(di => di.SectionName.Equals(section)).Count();
                            if (itemfound == 0)
                                continue;
                            if (itemfound == 1 && string.IsNullOrEmpty(changeSet.Items.Where(di => di.SectionName.Equals(section)).FirstOrDefault().FieldName) == true)
                                continue;
                            TableHeaderRow newHeaderRow = new TableHeaderRow();
                            historyInformation.Rows.Add(newHeaderRow);
                            TableHeaderCell newHeaderCell = new TableHeaderCell()
                            {
                                ColumnSpan = 2,
                                Text = section
                            };
                            newHeaderRow.Cells.Add(newHeaderCell);


                            Table dataAreaTable = new Table()
                            {
                                BackColor = Color.FromArgb(255, 255, 255),                         
                                BorderStyle = BorderStyle.Solid,
                                BorderWidth = Unit.Pixel(1),
                                CellPadding = 5,
                                CellSpacing = 0


                            };
                            dataAreaTable.Style.Add("table-layout", "fixed");


                            TableRow dataAreaRow = new TableRow();
                            dataAreaRow.Cells.Add(new TableCell() { Width = Unit.Pixel(10) });
                            historyInformation.Rows.Add(dataAreaRow);


                            TableCell dataAreaCell = new TableCell();
                            dataAreaCell.Controls.Add(dataAreaTable);
                            dataAreaRow.Cells.Add(dataAreaCell);


                            rowCount = 0;
                            foreach (CycleChangesetDifferenceItem item in changeSet.Items.Where(di => di.SectionName.Equals(section)))
                            {
                                rowCount += 1;


                                if (1 == rowCount)
                                {
                                    TableHeaderRow headerLabels = new TableHeaderRow();
                                    dataAreaTable.Rows.Add(headerLabels);
                                    string nextChangeset = (changeSet.CycleChangeset + 1).ToString();
                                    if (cp.cycleChangesetCount == changeSet.CycleChangeset)
                                    {
                                        nextChangeset = "Current";
                                    }
                                    headerLabels.Cells.Add(new TableHeaderCell() { CssClass = "changeHistoryHeaderText", HorizontalAlign = HorizontalAlign.Center, Width = Unit.Pixel(175), Text = "Field" });
                                    headerLabels.Cells.Add(new TableHeaderCell() { CssClass = "changeHistoryHeaderText", HorizontalAlign = HorizontalAlign.Center, Width = Unit.Pixel(212), Text = "Changeset " + changesetId });
                                    headerLabels.Cells.Add(new TableHeaderCell() { CssClass = "changeHistoryHeaderText", HorizontalAlign = HorizontalAlign.Center, Width = Unit.Pixel(212), Text = "Changeset " + nextChangeset });
                                    int headerCellCount = 0;
                                    foreach (TableHeaderCell cell in headerLabels.Cells)
                                    {
                                        if (1 < (headerCellCount += 1))
                                            cell.Style.Add("border-left", "1px #000000 solid");
                                    }
                                }


                                if (item.FieldName != "Cycle Changeset Comments")
                                {
                                    TableRow newRow = new TableRow();
                                    dataAreaTable.Rows.Add(newRow);
                                    newRow.Cells.Add(new TableCell() { CssClass = "applicationText", HorizontalAlign = HorizontalAlign.Left, Width = Unit.Pixel(175), Text = item.FieldName });
                                    newRow.Cells.Add(new TableCell() { CssClass = "applicationText", HorizontalAlign = HorizontalAlign.Left, Width = Unit.Pixel(212), Text = item.ChangesetValue });
                                    newRow.Cells.Add(new TableCell() { CssClass = "applicationText", HorizontalAlign = HorizontalAlign.Left, Width = Unit.Pixel(212), Text = item.CurrentValue });
                                    int cellCount = 0;
                                    foreach (TableCell cell in newRow.Cells)
                                    {
                                        if (1 < (cellCount += 1))
                                            cell.Style.Add("border-left", "1px #000000 solid");
                                        cell.Style.Add("border-top", "1px #000000 solid");
                                    }
                                }
                            }
                        }


                        TableRow spacerRow = new TableRow();
                        spacerRow.Cells.Add(new TableCell() { ColumnSpan = 2, Text = "&nbsp;", Height = Unit.Pixel(15) });
                        historyInformation.Rows.Add(spacerRow);


                        TableHeaderRow commentHeaderRow = new TableHeaderRow();
                        commentHeaderRow.Cells.Add(new TableHeaderCell() { ColumnSpan = 2, Text = "Comments" });
                        historyInformation.Rows.Add(commentHeaderRow);


                        foreach (CycleChangesetCommentItem comment in changeSet.Comments)
                        {
                            TableRow newRow = new TableRow();
                            newRow.Cells.Add(new TableCell() { Width = Unit.Pixel(10) });
                            newRow.Cells.Add(new TableCell() { Text = comment.Comment });
                            historyInformation.Rows.Add(newRow);
                        }


                        headerItem.Controls.Add(historyInformation);
                    }
                    else
                    {
                        string cycleNumber = headerItem.Value.Substring((headerItem.Value.IndexOf(":") + 1));
                        var changeSets = CycleChangesets.Where(ccs => ccs.CycleNumber == cycleNumber).OrderByDescending(ccs => ccs.CycleChangeset);                    


                        short changeSetCount = 0;
                        foreach (CycleChangeHistoryInformation changeSet in changeSets)
                        {
                            string nextChangeset = (changeSet.CycleChangeset + 1).ToString();                        
                            string creatorId = string.Empty;
                            string userDate = string.Empty;
                            if (null != changeSet.UpdateDate && changeSet.UpdateDate != DateTime.MinValue)
                                userDate = string.Format("- Date: {0}", changeSet.UpdateDate.ToShortDateString());
                            if (changeSets.Count() == changeSet.CycleChangeset)
                            {
                                nextChangeset = "Current";
                                int ccs = changeSet.CycleChangeset + 1;
                                creatorId = (from mu in MembershipDataProvider.LoadMembershipUsers(false)
                                             where mu.UserId == base.JcnData.Cycles.Where(cn => cn.CycleId == changeSet.CycleId && cn.CycleChangeSet == ccs).FirstOrDefault().CycleChangeSetCreatorId
                                             //where mu.UserId == base.CurrentUser //base.JcnData.Cycles.Where(cn => cn.CycleId == changeSet.CycleId  && cn.CycleChangeSet == changeSet.CycleChangeset).FirstOrDefault().CycleChangeSetCreatorId
                                             select string.Format("{0} {1}", mu.FirstName, mu.LastName)).FirstOrDefault();
                            }
                            else
                                creatorId = changeSet.CycleChangeSetCreatorId;
                          
                            RadPanelItem changeSetBlock = new RadPanelItem()
                            {
                                Text = string.Format("Changeset: {0} - {1}, User: {2} {3}", changeSet.CycleChangeset, nextChangeset, creatorId, userDate),
                                Expanded = false,
                                ClientIDMode = ClientIDMode.Inherit,
                                TabIndex = changeSetCount,
                                Value = string.Format("CycleNumber:{0}|CycleChangeSet:{1}", cycleNumber, changeSet.CycleChangeset),
                                PostBack = true,
                                ClickedCssClass = "rpOut"
                            };


                            changeSetBlock.HoveredImageUrl = null;
                            changeSetBlock.BackColor = Color.FromArgb(173, 0, 0);
                            headerItem.Items.Add(changeSetBlock);
                            changeSetCount += 1;
                        }
                    }
                }
            }



    Please see attached file with this email.

    Thanks
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 02 Nov 2011 Link to this post

    Hi Dharmesh,

    I was not able to reproduce the appearance that you have on the image attached but I am sending you a simple runnable page where I implement the styles that I believe you are trying to achieve. I also set the ExpandMode in the code behind. Please take a look at page and let me know if I am missing something. In case it does nit help I would need either a live url or a simplified runnable page (with minimum code and styles applied that demonstrates the issue) so we can observe it locally and help you out with a suitable solution.    

    Kind regards,
    Kate
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dharmesh
    Dharmesh avatar
    3 posts
    Member since:
    Jul 2011

    Posted 02 Nov 2011 Link to this post

    Hi,

    I need to apply back ground color as light blue and i dont need hover style in panel bar. I try to use your code still it didnt fix problem. I dont have any problem in chrome but in IE its not working.

    Following code fix problem for back ground color in chrome(light blue) but in IE i can still see Maroon.

     

     

    .RadPanelBar_Windows7 .rpGroup .rpOut .rpTemplate

     

    {

     

    FONT-SIZE: 12px; BORDER-BOTTOM-WIDTH: 0px; LINE-HEIGHT: 22px; BACKGROUND-COLOR:#C6D3DE }

     


    Following code fix problem for Hover in chrome but in IE still apply hover style.

    .RadPanelBar_Windows7

     

     

    .rpOut .rpText

     

    {

     

     

    background-color: #AC0000;

     

    }


    I am attaching two screen shots that i took one from IE and one from Chrome so its easy to understand. Let me know if you need further information.

    Thanks.

  5. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 07 Nov 2011 Link to this post

    Hi Dharmesh,

    Can you please send us either a live url or open a support ticket and attach a simplified runnable project that we could modify locally since I am not able to reproduce your issue only from the attached images? Can you also clarify the version of the IE browser where the styles do not take effect?

    Thank you in advance.

    All the best,
    Kate
    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
  6. Fayaz
    Fayaz avatar
    2 posts
    Member since:
    Apr 2013

    Posted 24 Apr 2013 Link to this post

    Hi Team I am not able to set the Backcolor of the RadItemPanel .Its showing error message like "Object reference not set to an instance of an object."


    this is my code.

    RegionalWorkflow cRegionalWorkflow;

    RadPanelItem panelItem;

    foreach (DomainCode dc in listClarifyRegions)

    {

    cRegionalWorkflow = (RegionalWorkflow)Page.LoadControl("~/UserControl/RegionalWorkflow.ascx");

    cRegionalWorkflow.Region = dc.CodeValue;

    panelItem = new RadPanelItem(dc.CodeValue);

    panelItem.Controls.Add(cRegionalWorkflow);

    // Here the error is thrown

    panelItem.Header.BackColor = Color.Silver;

    GSPOPanelBar.Items[0].Items.Add(panelItem);

    }



    Can you please tell me how to set the radpanel backcolor.

  7. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 29 Apr 2013 Link to this post

    Hello,

    It seems that this is caused by missing header template container of the RadPanelBar item. In order to avoid that behavior I would suggest adding a header template at run time and then apply some modifications to that header.
    Here you may find more information about adding RadPanelBar item templates at run-time and following that pattern you can add header template as well.

    Kind regards,
    Boyan Dimitrov
    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
UI for ASP.NET Ajax is Ready for VS 2017