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

[Solved] GridViewDataColumn Template Issue

1 Answer 172 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
rohan
Top achievements
Rank 1
rohan asked on 22 Sep 2010, 03:05 PM
Hi,

I am facing an issue while modifying the GridViewDataColumn.

Attached is the image of the requirement that i need to accomplish. I have already set the template using the grid in the datatemplate. Below is my code for it.

<telerik:GridViewDataColumn x:Name="columnValue1" UniqueName ="Value"  Width="300">
       <telerik:GridViewDataColumn.Header>
             <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                 </Grid.ColumnDefinitions>
                 <TextBlock Text="Value ($)" HorizontalAlignment="Center" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="6"/>
                 <TextBlock Text="Qtr1" Foreground="White" FontStyle="Normal" Grid.Row="1" Grid.Column="0"/>
                 <TextBlock Text="Qtr2" Foreground="White" FontStyle="Normal" Grid.Row="1" Grid.Column="1"/>
                 <TextBlock Text="Qtr3" Foreground="White" FontStyle="Normal" Grid.Row="1" Grid.Column="2"/>
                 <TextBlock Text="Qtr4" Foreground="White" FontStyle="Normal" Grid.Row="1" Grid.Column="3"/>
                 <TextBlock Text="Qtr5" Foreground="White" FontStyle="Normal" Grid.Row="1" Grid.Column="4"/>
                 <TextBlock Text="Qtr6" Foreground="White" FontStyle="Normal" Grid.Row="1" Grid.Column="5"/>
          </Grid>
          </telerik:GridViewDataColumn.Header>
          <telerik:GridViewDataColumn.CellTemplate>
               <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <TextBlock Text="{Binding Value1, Mode=TwoWay}" Grid.Row="1" Grid.Column="0"/>
                        <TextBlock Text="{Binding Value2, Mode=TwoWay}" Grid.Row="1" Grid.Column="1"/>
                        <TextBlock Text="{Binding Value3, Mode=TwoWay}" Grid.Row="1" Grid.Column="2"/>
                        <TextBlock Text="{Binding Value4, Mode=TwoWay}" Grid.Row="1" Grid.Column="3"/>
                        <TextBlock Text="{Binding Value5, Mode=TwoWay}" Grid.Row="1" Grid.Column="4"/>
                        <TextBlock Text="{Binding Value6, Mode=TwoWay}" Grid.Row="1" Grid.Column="5"/>
                  </Grid>
              </DataTemplate>
         </telerik:GridViewDataColumn.CellTemplate>
         <telerik:GridViewDataColumn.CellEditTemplate>
                 <DataTemplate>
                      <Grid>
                           <Grid.RowDefinitions>
                              <RowDefinition/>
                           </Grid.RowDefinitions>
                           <Grid.ColumnDefinitions>
                              <ColumnDefinition />
                              <ColumnDefinition />
                              <ColumnDefinition />
                              <ColumnDefinition />
                              <ColumnDefinition />
                              <ColumnDefinition />
                           </Grid.ColumnDefinitions>
             <TextBox Text="{Binding Value1, Mode=TwoWay}" Grid.Row="1" Grid.Column="0"/>
             <TextBox Text="{Binding Value2, Mode=TwoWay}" Grid.Row="1" Grid.Column="1"/>
             <TextBox Text="{Binding Value3, Mode=TwoWay}" Grid.Row="1" Grid.Column="2"/>
             <TextBox Text="{Binding Value4, Mode=TwoWay}" Grid.Row="1" Grid.Column="3"/>
             <TextBox Text="{Binding Value5, Mode=TwoWay}" Grid.Row="1" Grid.Column="4"/>
             <TextBox Text="{Binding Value6, Mode=TwoWay}" Grid.Row="1" Grid.Column="5"/>
             </Grid>
         </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
  </telerik:GridViewDataColumn>

And my grid is getting viewed in a similar fashion. Now i simply want to hide some of the quarter columns according to the quarter count. So from the code behind according to the count value of "Number of Quarters" i simply wish to hide some the textboxes and textblocks. Is this achievable? and if yes. How will i be able to achieve it.

It would be great if anyone can post a sample of this.

Thanks and Regards,
Rohan Kondvilkar

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 22 Sep 2010, 04:26 PM
Hi rohan,

Basically, you can just set the Visibility Property of those elements to Collapsed, depending on your custom logic. However, if you want to achieve a merging of column headers, you may take a look at this blog post.

Sincerely yours,
Maya
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
rohan
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or