Bug Report B209790
Visible to All Users

Conditional Appearance BackColor not working as expected for LayoutGroups and TabbedGroups

created 13 years ago

Please look at the attached project. There are a couple of ConditionalAppearance rules defined for MyDomainObject. The rules modify the BackColor of the layout groups to pink. The layout for MyDomainObject in the model defines a LayoutGroup and a separate TabbedGroup.
The actual output looks like this this.
However the output I would like (in both cases) is where the whole layout group is pink this.

Answers

created 13 years ago (modified 8 years ago)

Hello Robert,

This is by design. We have not implemented the full layout group painting. If you wish to change the appearance of the entire application, it is better to customize the web theme (see Customizing Theme Source Files). Otherwise, you can use the WebLayoutManager.ItemCreated event to change the particular control's appearance. Here is the simplified example:

C#
using System; using System.Drawing; using System.Web.UI; using System.Web.UI.WebControls; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Model; using DevExpress.ExpressApp.Web.Layout; using DevExpress.Web; namespace MainDemo.Module.Web { public class ViewController1 : ViewController<DetailView> { protected override void OnActivated() { base.OnActivated(); ((WebLayoutManager)View.LayoutManager).ItemCreated += ViewController1_ItemCreated; } void ViewController1_ItemCreated(object sender, ItemCreatedEventArgs e) { if (e.ModelLayoutElement is IModelLayoutGroup && ((IModelLayoutGroup)e.ModelLayoutElement).ShowCaption == true) { e.TemplateContainer.Init += TemplateContainer_Init; } } void TemplateContainer_Init(object sender, EventArgs e) { LayoutItemTemplateContainerBase templateContainer = (LayoutItemTemplateContainerBase)sender; templateContainer.Init -= TemplateContainer_Init; PaintRecursive(templateContainer); } private void PaintRecursive(Control control) { foreach (Control childControl in control.Controls) { if (childControl is ASPxEdit) return; if (childControl is WebControl) { ((WebControl)childControl).BackColor = Color.Yellow; } PaintRecursive(childControl); } } protected override void OnDeactivated() { base.OnDeactivated(); ((WebLayoutManager)View.LayoutManager).ItemCreated -= ViewController1_ItemCreated; } } }

Please let me know if you need any further assistance.

    Show previous comments (6)
    Andrey K (DevExpress Support) 7 years ago

      Hello,

      Thank you for the clarification. Indeed, when the new web UI is used, we apply CSS rules to tabs. That is why the code you showed doesn't work anymore.

      The easiest way to accomplish this task is to override the CSS rules we are using. For this, add the following style to the Default.aspx page:

      CSS
      <style media="screen" type="text/css"> .LayoutTabbedGroupContainer .dxtcLite_XafTheme > .dxtc-stripContainer .dxtc-activeTab, .LayoutTabbedGroupContainer .dxtcLite_XafTheme.dxtc-noSpacing > .dxtc-stripContainer .dxtc-activeTab.dxtc-lead, .LayoutTabbedGroupContainer .dxtcLite_XafTheme.dxtc-noSpacing > .dxtc-stripContainer .dxtc-activeTab { background-color: green !important; } </style>

      I modified the E372: How to access a tab control in a Detail View layout example accordingly. Try it and let me know whether it helps.

      I suggest that you also review the K18570: How to inspect CSS rules article to learn how to find and change the appearance of HTML elements.

      Let us know if you have any further questions.

      Thanks,
      Andrey

        I need conditional applied style not permanent , how to achieve this

        C#
        .... if (!string.IsNullOrEmpty(((Customer)View.CurrentObject).SpecialAgreement)) { e.PageControl.ClientSideEvents.Init = "function(s,e){s.SetActiveTabIndex(3);}"; e.PageControl.ActiveTabStyle.BackColor = System.Drawing.Color.Yellow; // doesnt work } ...
        Anatol (DevExpress) 7 years ago

          You can declare a custom CSS class with the required background color and assign the page control's CssClass property conditionally. Here is a MainDemo-based example:

          C#
          using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Web.Layout; using DevExpress.Web; using MainDemo.Module.BusinessObjects; namespace MainDemo.Module.Web { public class ContactTabsColorController : ObjectViewController<DetailView, Contact> { ASPxPageControl pageControl; protected override void OnActivated() { base.OnActivated(); ((WebLayoutManager)View.LayoutManager).PageControlCreated += LayoutManager_PageControlCreated; View.CurrentObjectChanged += View_CurrentObjectChanged; } void View_CurrentObjectChanged(object sender, EventArgs e) { UpdatePageControlStyle(); } void LayoutManager_PageControlCreated(object sender, PageControlCreatedEventArgs e) { pageControl = e.PageControl; UpdatePageControlStyle(); } private void UpdatePageControlStyle() { if (pageControl != null) { pageControl.CssClass = ViewCurrentObject != null && ViewCurrentObject.Manager != null ? "yellowBackColor" : ""; } } protected override void OnDeactivated() { base.OnDeactivated(); ((WebLayoutManager)View.LayoutManager).PageControlCreated -= LayoutManager_PageControlCreated; View.CurrentObjectChanged -= View_CurrentObjectChanged; } } }

          Note that since built-in CSS settings also declare the background-color style with the important modifier, it is necessary to create a selector that overrides these styles. Use the browser's Development Tools to determine which selectors should be overridden and embed the yellowBackColor class there. Here is an example:

          ASPx
          .LayoutTabbedGroupContainer .yellowBackColor.dxtcLite_XafTheme.dxtc-noSpacing > .dxtc-stripContainer .dxtc-activeTab { background-color: yellow !important; } .yellowBackColor.dxtcLite_XafTheme.dxtc-noSpacing > .dxtc-stripContainer .dxtc-activeTab { background-color: yellow !important; } .yellowBackColor .dxtc-content { background-color: yellow !important; }

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.