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

Custom row layout with update and insert

3 Answers 190 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alp
Top achievements
Rank 1
Alp asked on 25 Aug 2010, 03:45 PM
I was trying to follow along the demo RadControls for WPF -> Data -> GridView -> Appearance -> Custom Row Layout.
I am using a dataset as data source.  It works fine by default but I can't bind to columns after I apply RowStyle property.  I set up a 3 by 2 grid as custom layout and I can see the TextBlocks that are labels.  The TextBlocks that I bind columns do not display data.  Any ideas?

Here is my template
<ControlTemplate x:Key="MyCustomRowTemplate" TargetType="telerik:GridViewRow">
                <Border x:Name="rowsContainer" Background="#FF525252" Padding="8,8,8,0">
                    <Border Background="{StaticResource Office_BlackRowBackground}" x:Name="selectedRow"
                        BorderThickness="1" BorderBrush="#FF000000">
  
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />                                
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
  
                            <TextBlock Text="Code:"
                                       Grid.Column="0" Grid.Row="0"
                                       VerticalAlignment="Top" HorizontalAlignment="Left" 
                                       Foreground="White" FontWeight="Bold" Margin="0,15,15,0" />
  
                            <TextBlock Text="{Binding CD}"
                                       Grid.Column="1" Grid.Row="0"
                                       VerticalAlignment="Top" HorizontalAlignment="Left"
                                       Foreground="White"  Margin="0,15,15,0" />
                              
                            <TextBlock Text="Description:"
                                       Grid.Column="0" Grid.Row="1"
                                       VerticalAlignment="Top" HorizontalAlignment="Left" 
                                       Foreground="White" FontWeight="Bold" Margin="0,15,15,0" />
  
                            <TextBlock Text="{Binding DESC}"  
                                       Grid.Column="1" Grid.Row="1"
                                       VerticalAlignment="Top" HorizontalAlignment="Left"
                                       Foreground="White"  Margin="0,15,15,0" />
                              
                            <TextBlock Text="Enabled:"
                                       Grid.Column="0" Grid.Row="2"
                                       VerticalAlignment="Top" HorizontalAlignment="Left" 
                                       Foreground="White" FontWeight="Bold" Margin="0,15,15,0" />
  
  
                            <TextBlock Text="{Binding ENABLED}"
                                       Grid.Column="1" Grid.Row="2"
                                       VerticalAlignment="Top" HorizontalAlignment="Left"
                                       Foreground="White"  Margin="0,15,15,0" />
  
                        </Grid>
                    </Border>
                </Border>
            </ControlTemplate>

and gridview
<telerik:RadGridView Grid.Row="2" Name="radGridView2" ItemsSource="{Binding}" 
                             Margin="5,5,5,5" HorizontalAlignment="Left" Visibility="Hidden" 
                             IsFilteringAllowed="False" RowSytle="{StaticResource rowStyle}" 
                             ShowGroupPanel="False" ShowColumnHeaders="False"  
                             RowIndicatorVisibility="Collapsed" CanUserReorderColumns="False"  />

Thanks

3 Answers, 1 is accepted

Sort by
0
Kalin Milanov
Telerik team
answered on 26 Aug 2010, 08:12 AM
Hello Alp,

By the looks of it the problem resides in a faulty binding of the RadGridView, or an incorrect application of the RowStyle. In any case the custom row template is fine. 

I am sending you a sample I used for testing the template and it works like a charm. Maybe you can use it as a reference to pinpoint the problem.

Let me know how this goes.

Sincerely yours,
Kalin Milanov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Alp
Top achievements
Rank 1
answered on 26 Aug 2010, 04:51 PM
Thanks.  Your sample does work like a charm.  I copied your Window.Resources definition and I still can't get the data on mine when I apply the RowStyle property. 

I have another GridView which I allow row selection.  When a row is selected on the first GridView, the second one displays the details (more columns) of that single record.  If I don't set the RowStyle for the second GridView, I see the correct data.  But if I set the RowStyle, I do see the 3x2 layout with the labels but not the data from the dataset.  I set the radGridView2.DataContext to a function which returns a dataset on the radGridView1_RowActivated event.
Do I have to define the datasource for the template or the application?  Would the template be able to look into the second GridView and know what it is?

Also I want to allow editing and inserting of data on the second GridView.  Would I need to use GridViewCell instead of TextBlock?
0
Kalin Milanov
Telerik team
answered on 01 Sep 2010, 01:36 PM
Hi Alp,

I modified the previous sample to account for the selection specifics you mentioned. The style still applies and everything looks as expected. Is this your case or am I missing something?

As for the editing - right now it is not possible to perform it when implementing custom rows. 

Regards,
Kalin Milanov
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Alp
Top achievements
Rank 1
Answers by
Kalin Milanov
Telerik team
Alp
Top achievements
Rank 1
Share this question
or