Ticket Q445661
Visible to All Users

Back color of column header in MVC gridview only covers half of the header area

created 12 years ago

Hi.

I am trying to modify the back color of the column header in a gridview. We are using MVC/Razor. When we set the back color attribute, the gridview renders with the color only filling about half of the column header area. I'm using the .Styles.Header.BackColor attribute. I've attached an image of what is showing.

Any information about how to manipulate this attribute and others in the column header would be appreciated.

I'm fairly new to DevExpress and MVC in general so please provide a detailed answer if possible.

Best,

John

Comments (2)
DevExpress Support Team 12 years ago

    Hello John,
    This property should work fine. Your screenshot makes me think that you are using header templates and a theme. So, to provide you with a precise solution, send us your GridView markup and CSS styles. Your cooperation is highly appreciated.

      Hi Marion.
      I haven't tried applying a template or a theme so if I did do that it was purely by accident! Here is the code I have in the view:
      @using DevExpress.Web.Mvc.UI
      @using System.Web.UI.WebControls
      @using System
          @Html.DevExpress().GridView(
              settings =>
              {
                  settings.Name = "SubsidiariesGrid";
                  settings.CallbackRouteValues = new { Controller = "Subsidiaries", Action = "SubsidiariesGridPartial"};
                  settings.KeyFieldName = "SubsidiaryID";
                  settings.Columns.Add("SubsidiaryName");
                  settings.Columns.Add("AddressLine1");
                  settings.Columns.Add("AddressLine2");
                  settings.Columns.Add("City");
                  settings.Columns.Add("State");
                  settings.Columns.Add("PostalCode");
                  settings.Columns.Add("Description");
                  settings.Columns.Add("PercentOwned");
                  settings.Columns.Add(column =>
                  {
                      column.Caption = "Delete";
                      column.FieldName = "SubsidiaryDelete";
                      column.Width = 50;
                      column.ColumnType = DevExpress.Web.Mvc.MVCxGridViewColumnType.CheckBox;
                  });
                  settings.Settings.ShowColumnHeaders = true;
                  settings.Settings.ShowVerticalScrollBar = true;
                  settings.Settings.VerticalScrollableHeight = 500;
                  settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                  settings.SettingsBehavior.AllowSelectSingleRowOnly = true;
                  settings.SettingsBehavior.AllowSelectByRowClick = true;
                  settings.SettingsBehavior.AllowFocusedRow = true;
                  settings.SettingsBehavior.AllowDragDrop = true;
                  settings.SettingsBehavior.AllowSort = true;
                  settings.SettingsBehavior.ColumnResizeMode = DevExpress.Web.ASPxGridView.ColumnResizeMode.NextColumn;
                  settings.Styles.AlternatingRow.BackColor = System.Drawing.Color.AliceBlue;
                  settings.Styles.Header.BackColor = System.Drawing.Color.LightSkyBlue;
                  settings.Styles.Header.ForeColor = System.Drawing.Color.Black;
              }).Bind(Model).GetHtml()

      Answers

      created 12 years ago (modified 12 years ago)

      Hello John,
      I do not see a potential cause of this issue in the provided code snippet. At the same time, the issue looks similar to issues discussed in the following tickets:
      ASPxGridView - Change color of Column header by condition when using theme
      ASPxGridView - How to set a background color of columns if ASPxGridView is displayed with a theme
      The tickets are devoted to the ASPxGridView, but you can use corresponding GridView settings to achieve the same result.
      If this does not help you solve the issue, would you please provide me with a test project to illustrate the issue?

        Comments (2)

          Thanks for pointing me in the right direction. I did notice that a default theme was set in the web.config file. I used the Theme Builder tool to see that an image is used in the column header that blocks the background color from being completely displayed. I ended up creating a new theme and removed the image file to get the background color I needed. Maybe this solution was intuitive for some but I think it might be nice to provide better messaging about when to use Theme Builder in your documentation

          DevExpress Support Team 12 years ago

            Hello John,
            I am glad to hear that you have found an appropriate solution to this issue. The use of the ASPxThemeBuilder tool is one of good approaches if you need to modify one of DevExpress themes. Please refer to the ASPxThemeBuilder topic to learn more about the use of this tool.
            Feel free to contact me if you have any other questions.

            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.