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

CellTemplate With Textboxes

4 Answers 274 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Jonah
Top achievements
Rank 1
Jonah asked on 15 May 2014, 04:41 PM
In my gridview, I have a column that I need to make into a template as follows.
​ <telerik:GridViewDataColumn Header="Contact" DataMemberBinding="{Binding CustAccountsLocationContact.FirstName}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding CustAccountsLocationContact.FirstName}" />
<TextBlock Text=" " />
<TextBlock Text="{Binding CustAccountsLocationContact.LastName}" />
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>


When I save and reload with persistence framework, the binding no longer works. Is there a work around for this? or do I just need to add 2 columns?

Thank you,
Jonah

4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 19 May 2014, 03:58 PM
Hi Jonah,

Keep in mind that if your bindings Mode is set to OneWay the PersistenceFramework may not save them correctly. In order to save the bindings you can set their Mode to TwoWay or exclude the elements with those bindings from the persisted controls. Here is an example in code:
<Grid>
    <telerik:PersistenceManager.SerializationOptions>
        <telerik:SerializationMetadataCollection>
            <telerik:PropertyNameMetadata Condition="Except"
                             Expression="Children"
                             SearchType="PropertyName" />
        </telerik:SerializationMetadataCollection>
    </telerik:PersistenceManager.SerializationOptions>
    <TextBlock Text="{Binding Name}"/>
</Grid>
This will not persist the properties of the elements in the Grid's Children collection (in this case only the TextBlock).

You can also take a look at the following forum.

Please let me know if this helps. 

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jonah
Top achievements
Rank 1
answered on 20 May 2014, 02:00 PM
I tried setting the binding mode to twoway and that didn't seem to change anything. The only thing I am saving the settings for is the GridView so if I except the children of that, wouldn't it make saving anything pointless? below is my full gridview xaml, there are other controls on the page that I am not saving.

​ <telerik:RadGridView ItemsSource="{Binding OrderList}" AutoGenerateColumns="False" Grid.Row="2" GroupRenderMode="Flat" CanUserSortGroups="False" IsReadOnly="True" ShowGroupPanel="False"
RowIndicatorVisibility="Collapsed" x:Name="SearchAccountGrid" SelectionMode="Extended"
FrozenColumnsSplitterVisibility="Collapsed" SelectedItem="{Binding SelectedOrder, Mode=TwoWay}">

<telerik:RadGridView.ControlPanelItems>
<telerik:ControlPanelItem ButtonTooltip="Column chooser">
<telerik:ControlPanelItem.ButtonContent>
<Grid HorizontalAlignment="Center" Height="16" Width="16" Margin="-3,0,0,0">
<Path Data="M2.6822092E-06,12.000001 L6.0000029,12.000001 L6.0000029,15.000001 L2.6822092E-06,15.000001 z M2.6822092E-06,8.000001 L6.0000029,8.000001 L6.0000029,11.000001 L2.6822092E-06,11.000001 z M0,0 L6,0 L6,3 L0,3 z" Fill="{telerik:Windows8Resource ResourceKey=StrongBrush}" Margin="4,0,9,0" Stretch="Fill"/>
<Path Data="M0,0 L6,0 L6,3 L0,3 z" Fill="{telerik:Windows8Resource ResourceKey=StrongBrush}" Height="3" Margin="4,4,9,0" Stretch="Fill" VerticalAlignment="Top"/>
<Path Data="M3,0 L3,3 L0,3 z" Fill="{telerik:Windows8Resource ResourceKey=StrongBrush}" HorizontalAlignment="Left" Height="3" Margin="0,4,0,0" Stretch="Fill" Stroke="{telerik:Windows8Resource ResourceKey=StrongBrush}" StrokeThickness="0" VerticalAlignment="Top" Width="3" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<RotateTransform Angle="-45"/>
<ScaleTransform ScaleX="-2.3299793205922015E-08" ScaleY="4.4408920985006262E-16">
</ScaleTransform>
</TransformGroup>
</Path.RenderTransform>
</Path>
<Path Data="M0.50000036,12.499999 L2.5000005,12.499999 L2.5000005,14.499999 L0.50000036,14.499999 z M0.5,8.5 L2.5000002,8.5 L2.5000002,10.5 L0.5,10.5 z M0.5,4.5 L7.5,4.5 L7.5,6.5 L0.5,6.5 z M0.5,0.5 L7.5,0.5 L7.5,2.5 L0.5,2.5 z" HorizontalAlignment="Right" Stretch="Fill" Stroke="#FF767676" Width="8"/>
</Grid>
</telerik:ControlPanelItem.ButtonContent>
<telerik:ControlPanelItem.Content>
<ListBox ItemsSource="{Binding Columns}" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Header, Mode=OneWay}" IsChecked="{Binding IsVisible, Mode=TwoWay}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</telerik:ControlPanelItem.Content>
</telerik:ControlPanelItem>
</telerik:RadGridView.ControlPanelItems>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Order Number" DataMemberBinding="{Binding OrderID}" />
<telerik:GridViewDataColumn Header="Order Type" DataMemberBinding="{Binding OrderTypeID}" />
<telerik:GridViewDataColumn Header="Account Name" DataMemberBinding="{Binding BillingName}" />
<telerik:GridViewDataColumn Header="Ship To" DataMemberBinding="{Binding ShipName}" />
<telerik:GridViewDataColumn Header="Purchase Order" DataMemberBinding="{Binding PurchaseOrder}" />
<telerik:GridViewDataColumn Header="Misc Job Info" DataMemberBinding="{Binding ShipMisc1}" />
<telerik:GridViewDataColumn Header="Misc Job Info" DataMemberBinding="{Binding ShipMisc2}" />
<telerik:GridViewDataColumn Header="Account Number" DataMemberBinding="{Binding AccountLocationID}" />
<telerik:GridViewDataColumn Header="Contact">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding CustAccountsLocationContact.FirstName, Mode=TwoWay}" />
<TextBlock Text=" " />
<TextBlock Text="{Binding CustAccountsLocationContact.LastName, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn Header="Order Date" DataMemberBinding="{Binding OrderDate}" DataFormatString="{}{0:M/dd/yyyy}" />
<telerik:GridViewDataColumn Header="Order Total" DataMemberBinding="{Binding GrandTotal}" DataFormatString="{}{0:c}" />
</telerik:RadGridView.Columns>
<i:Interaction.Behaviors>

<util:SelectedSyncBehavior SelectedItems="{Binding SelectedOrders}" />
</i:Interaction.Behaviors>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding SaveClose}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</telerik:RadGridView>
0
Martin Ivanov
Telerik team
answered on 23 May 2014, 01:25 PM
Hi Jonah,

I prepared a project with the provided Xaml from your last reply, but I wasn't able to reproduce the bindings issue. I am saving the columns sorting, grouping and filtering with the PersistenceFramework. In addition I attached the project. Please give it a try and let me know if I am missing something.

If the project doesn't help, can you tell me how and what exactly you are saving. Also can you provide me with a sample project that isolates the issue. This will allow me to test it locally and investigate the reason behind the reported behavior.

Regards,
Martin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jonah
Top achievements
Rank 1
answered on 23 May 2014, 02:12 PM
Thank you, I added IsVisble to the column Proxy and applied the save & restore and that worked great.
Tags
PersistenceFramework
Asked by
Jonah
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Jonah
Top achievements
Rank 1
Share this question
or