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

Persistence Manager Issue

5 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 2
Alan asked on 22 Oct 2012, 01:03 PM
I am using RadGridView for WPF 2012.3.1017.40

There is some issue with the column header depending on the type of XAML I invoked

When I use:
<telerik:GridViewDataColumn UniqueName="Year"  Header="Year" />
The grid does persists with the expected header "Year"

However when I use:
<telerik:GridViewDataColumn UniqueName="Year" >
                    <telerik:GridViewDataColumn.Header>
                        <TextBlock Text="Year" />
                    </telerik:GridViewDataColumn.Header>
                </telerik:GridViewDataColumn>

The following is injected into the persisted XML
    <PV Key="12" TypeKey="-664072138">
      <Value xsi:type="xsd:string"<System.Windows.Controls.TextBlock</Value>
    </PV>
and instead of "Year" in the Column header the grid persists the words "System.Windows.Controls.TextBlock" into the header instead.

Please note, it appears to be an extra < being injected within the value element. However I need the word "Year" instead.

How can I fix this?
Thank you,
Alan Painter

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 22 Oct 2012, 01:56 PM
Hi Alan,

The Column's Header is an object and you have set it to be a TextBlock. The value persisted is the one returned from Header.ToString() which will return "System.Windows.Controls.TextBlock".
You will need to change the implementation a little bit and return the Text value for the TextBlock instead of relying on the default ToString() method.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alan
Top achievements
Rank 2
answered on 22 Oct 2012, 02:01 PM
Didie ~

If I am reading your reply correctly using XAML I am already doing this with:
<telerik:GridViewDataColumn UniqueName="Year" >
                    <telerik:GridViewDataColumn.Header>
                        <TextBlock Text="Year" />
                    </telerik:GridViewDataColumn.Header>
                </telerik:GridViewDataColumn>

And it does not work. Is there something else I need to be doing instead?

Thank you
0
Dimitrina
Telerik team
answered on 22 Oct 2012, 02:10 PM
Hi,

I meant that you could change the implementation persisting the values. If you have followed this example, then you could change this code to return the Text of the TextBlock in the Header:

foreach (GridViewColumn column in gridView.Columns)
{
    columnProxies.Add(new ColumnProxy()
    {
       UniqueName = column.UniqueName,
    Header = column.Header.ToString(),
      DisplayOrder = column.DisplayIndex,
        Width = column.Width,
  )};
}

Another possible solution would be to set the Header like so:
<telerik:GridViewDataColumn.Header>Year</telerik:GridViewDataColumn.Header>

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Alan
Top achievements
Rank 2
answered on 25 Oct 2012, 05:58 PM
In my situation I will need to apply style properties to the Header.

For example if I was able to use a TextBlock within the header I would invoke
        <Setter Property="FontFamily" Value="Arial" />
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="FontSize" Value="12" />
        <Setter Property="HorizontalAlignment" Value="Center" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="TextAlignment" Value="Center" />
        <Setter Property="VerticalAlignment" Value="Center" />

How can I do this in your example?

Thank you,
Alan Painter
0
Dimitrina
Telerik team
answered on 26 Oct 2012, 08:54 AM
Hello Alan,

You could then return the Text for the TextBlock when you are persisting the value. For example:

foreach (GridViewColumn column in gridView.Columns)
{
    columnProxies.Add(new ColumnProxy()
    {
       UniqueName = column.UniqueName,
       Header = (column.Header as TextBlock).Text,
       DisplayOrder = column.DisplayIndex,
       Width = column.Width,
  )};
}


All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Alan
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Alan
Top achievements
Rank 2
Share this question
or