This is a migrated thread and some comments may be shown as answers.

Changing dataItem.BackColor causes column issues

4 Answers 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Julian
Top achievements
Rank 1
Julian asked on 21 May 2015, 09:46 PM

I have the following code in my project:

 

protected void radGrid1_OnItemDataBound(object sender, GridItemEventArgs e)
      {
          var rowIndex = -1;
 
          if (e.Item is GridDataItem)
          {
              GridDataItem dataItem = e.Item as GridDataItem;   
 
              if ((dataItem[" "].Text == "<b>Total Capacity</b>") || (dataItem[" "].Text == "<b>Total Requested Capacity</b>")
                  || (dataItem[" "].Text == "<b>Total Remaining Capacity</b>"))
              {
                  rowIndex = dataItem.ItemIndex;
                  dataItem.BackColor = System.Drawing.ColorTranslator.FromHtml("#F7E69E");
 
              }
 
          }
 
      }

I've attached a screen shot. If you look at the column headers the last one is "4/2016". However the data is just gone. That whole column is blank. The colored rows do not extent into that column. If i drag select the columns on the screen it's like that column does not even exist. 

Any idea why a simple change such as this would cause an issue with the columns?

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 26 May 2015, 08:00 AM
Hi Julian,

From the provided screenshot it seems that the data is not aligned with the column headers. It would be hard to pinpoint the exact cause of this behavior. However, I would suggest couple of things that can help.

  • Make sure that there is no ItemStyle defined for the columns
  • In case the columns have defined Width use the HeaderStyle-Width property
  • Leave one column with no defined Width

Also, check out the following threads that discuss similar issues and see if the suggested solutions there are working for you.



Try to apply the changes and see how they work for you. In case the issue persists please share the complete markup for the RadGrid. Thus, we will be able to examine the code and look for what could cause the behavior.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Julian
Top achievements
Rank 1
answered on 26 May 2015, 01:23 PM
Thanks Viktor, I will look into the suggestions you made and have a response probably this evening in regards to those findings.
0
Viktor Tachev
Telerik team
answered on 28 May 2015, 01:55 PM
Hi Julian,

Thank you for getting back.

I will appreciate it if you share the results of your tests in the thread. This can help someone that is observing similar issues in the future.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Julian
Top achievements
Rank 1
answered on 28 May 2015, 02:07 PM

Viktor,

Yes I had planned on posted the results. Got stuck at a Company baseball game outing with about 150 employees yesterday! Still recovering.

The issue was indeed that the first column in my grid had it's with defined with "ItemStyle" instead of "HeaderStyle". Once I changed that the formatting issue went away. :)

 

 

  • Make sure that there is no ItemStyle defined for the columns
  • In case the columns have defined Width use the HeaderStyle-Width property
  • Leave one column with no defined Width
  • Tags
    Grid
    Asked by
    Julian
    Top achievements
    Rank 1
    Answers by
    Viktor Tachev
    Telerik team
    Julian
    Top achievements
    Rank 1
    Share this question
    or