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

System.Windows.Controls.TextBlock header on RadGridView

3 Answers 23 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 11 May 2015, 11:17 PM

I hesitate to count how many RadGridViews I have between the app currently being used in an Enterprise situation and the new app we're working hard on. But today I've been working an issue I have NEVER seen before.

I have two grids on a particular page that are *almost* identical. Both have some columns that the header is simply a piece of text written in the GridViewDataColumn "Header" property. Likewise both have some columns that we want the text to wrap, so I'm using a GridViewDataColumn.Header section with a TextBlock with wrapping properties. None of the header text is bound, it is simple text either as Header= or in a .Header section.

Today I noticed one of the grids is displaying "System.Windows.Controls.TextBlock" instead of the Header. And it doesn't matter if it is a Header section or simply a Header parameter.. not all fail but the ones that are failing are from both types of Header display.

To add insult to injury, I commented one out that wasn't working correctly (one with the wrapping setup), and copied the one above in the xaml and only changed the binding value and UniqueName... left the simple Header= property the same... and it STILL displays as "System.Windows.Controls.TextBlock".

If I had just initiated this grid, I'd say I had something wrong, but this has been working for quite a while, and all of a sudden it's not displaying simple header text.

I've compared all the Telerik references, and ensured they are the correct (consistent and latest) version.

Has anyone seen this before? What the heck is it doing?

And no... this is a grid on a usercontrol stuck inside a 44 project app, and the chance of me pulling it out into something small enough to send and have it still not work probably isn't worth the effort of trying...

-Dave

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 14 May 2015, 12:52 PM
Hi Dave,

I am sorry to hear you experience such an issue, it would be indeed strange that it only started occurring on one RadGridView. 

Generally, we are neither aware of such an issue, nor we had it reported before. RadGridView's Header is an object and you could directly assign any object for it. Would you please share how have you defined it exactly? What is the value of the property you are displaying as a Header? Is it eventually a TextBlock itself? Are you able to isolate the issue in a demo project and send it to us? You can open a new support ticket and attach the sample there.

Regards,
Dimitrina
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
Bruno
Top achievements
Rank 1
answered on 07 Jul 2017, 09:46 AM

Hello,

I just had the same issue and I'll post the solution here for future reference.

The cause of the issue is the Persistence Framework. If you are filling the Header property directly in one grid and using a TextBlock in the header of another grid, the issue occurs. The Persistence Framework needs to know how to retrieve the header text and it converts the TextBlock to a string, resulting in "System.Windows.Controls.TextBlock".

The solution is to retrieve the header text differently for the different cases. This needs to be done in both the ProvideValue and RestoreValue methods of the ICustomPropertyProvider.

string headerText;
var headerTextBlock = column.Header as System.Windows.Controls.TextBlock;
if (headerTextBlock != null)
{
    headerText = headerTextBlock.Text;
}
else
{
    headerText = column.Header.ToString();
}
 
columnProxies.Add(new ColumnProxy()
{
    UniqueName = column.UniqueName,
    Header = headerText,
    DisplayOrder = column.DisplayIndex,
    Width = column.Width,
});
0
Stefan
Telerik team
answered on 12 Jul 2017, 07:04 AM
Hello Bruno,

Thank you very much for sharing your solution with the community.

I have updated your Telerik points as a token of gratitude for this.

All the best,
Stefan X1
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Dave
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Bruno
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or