How to find the child controls in the Telerik RadGridView

1 posts, 0 answers
  1. Dinesh
    Dinesh avatar
    9 posts
    Member since:
    Nov 2012

    Posted 05 Dec 2012 Link to this post

    Hi,

    I'm new to Telerik Controls, i got a problem that i want find the controls in the telerik RadGridView i have tried like below code which was conmmented i was written in RowLoaded and also in DataLoaded events of RadGridView in the RowLoaded event only first header child controls are being updated but remaining header are left as it is, in DataLoaded Event none is binding as it showing as it is but no updated text in it.

    Following is my code in .xaml

    <telerik:RadGridView Name="GridViewSellIn"  
                                                         Visibility="Visible"
                                                         GridLinesVisibility="Both"
                                                         AutoGenerateColumns="False"
                                                         ShowColumnFooters="True"
                                                         IsReadOnly="True"
                                                         ShowGroupPanel="False"
                                                         CanUserSortColumns="False"
                                                         ShowGroupFooters="False"
                                                         ScrollMode="RealTime"
                                                         ShowInsertRow="False"
                                                         ShowColumnHeaders="True"  RowLoaded="GridViewSellIn_RowLoaded" DataLoaded="GridViewSellIn_DataLoaded"
                                                         RowIndicatorVisibility="Collapsed"
                                                         IsSynchronizedWithCurrentItem="False"
                                                         IsEnabled="True" CanUserSelect="False"
                                                         Width="690" Grid.Column="1"
                                                         Grid.Row="1"
                                                         HorizontalAlignment="Left"
                                                         Margin="10,5,0,0">
                                    <telerik:RadGridView.Columns>
                                        <telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn.Header>
                                                <Grid Background="#0070C0">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="170"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Border BorderThickness="1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="13" BorderBrush="Black">
                                                        <!--<TextBlock Grid.Row="0" Name="" Grid.Column="0" Grid.ColumnSpan="13" Text="" HorizontalAlignment="Center" VerticalAlignment="Center" />-->
                                                    </Border>
                                                    <Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="13" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="1" Name="" Grid.Column="0" Grid.ColumnSpan="13" Text=""  HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="2" Grid.Column="0" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="2" Grid.Column="0" Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="3" Grid.Column="0" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="3" Grid.Column="0"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                </Grid>
                                            </telerik:GridViewDataColumn.Header>
                                            <telerik:GridViewDataColumn.CellTemplate>
                                                <DataTemplate>
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="20"/>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="170"/>
                                                            <!--<ColumnDefinition Width="80"/>
                                                            <ColumnDefinition Width="80"/>
                                                            <ColumnDefinition Width="20"/>
                                                            <ColumnDefinition Width="80"/>-->
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Grid.Row="0" Grid.Column="0"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Grid>
                                                </DataTemplate>
                                            </telerik:GridViewDataColumn.CellTemplate>
                                        </telerik:GridViewDataColumn>
                                        <telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn.Header>
                                                <Grid Background="#0070C0">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="85"/>
                                                        <ColumnDefinition Width="85"/>
                                                        <ColumnDefinition Width="18"/>
                                                        <ColumnDefinition Width="55"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Border BorderThickness="1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" BorderBrush="Black">
                                                        <TextBlock Grid.Row="0" Name="" Grid.Column="0" Grid.ColumnSpan="4" Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="2" Grid.Column="1" Name="" Grid.ColumnSpan="4" Text=""  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="13" BorderThickness="1" BorderBrush="Black">

                                                    </Border>
                                                    <Border Grid.Row="4" Grid.Column="0" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="3" Grid.Column="1"  Text=""  HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="4" Grid.Column="1" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="3" Grid.Column="2"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="Black">
                                                        <StackPanel Orientation="Horizontal">
                                                            <TextBlock Grid.Row="4" Grid.Column="2"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                            <TextBlock Grid.Row="3" Grid.Column="4"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                        </StackPanel>
                                                    </Border>
                                                </Grid>
                                            </telerik:GridViewDataColumn.Header>
                                            <telerik:GridViewDataColumn.CellTemplate>
                                                <DataTemplate>
                                                    <Grid>
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="20"/>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="85"/>
                                                            <ColumnDefinition Width="85"/>
                                                            <ColumnDefinition Width="18"/>
                                                            <ColumnDefinition Width="55"/>
                                                            <!--<ColumnDefinition Width="75"/>
                                                            <ColumnDefinition Width="75"/>
                                                            <ColumnDefinition Width="18"/>
                                                            <ColumnDefinition Width="55"/>-->
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Grid.Row="0" Grid.Column="0"  Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        <TextBlock Grid.Row="0" Grid.Column="1"  Text=""  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        <Image Source="" Width="15" Height="15" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center"></Image>
                                                        <TextBlock Grid.Row="0" Grid.Column="3"  Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                    </Grid>
                                                </DataTemplate>
                                            </telerik:GridViewDataColumn.CellTemplate>
                                        </telerik:GridViewDataColumn>
                                        <telerik:GridViewDataColumn>
                                            <telerik:GridViewDataColumn.Header>
                                                <Grid Background="#0070C0">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                        <RowDefinition Height="18"/>
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="85"/>
                                                        <ColumnDefinition Width="85"/>
                                                        <ColumnDefinition Width="18"/>
                                                        <ColumnDefinition Width="55"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Border BorderThickness="1" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" BorderBrush="Black">

                                                    </Border>
                                                    <Border Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="2" Grid.Column="5" Name="" Grid.ColumnSpan="4" Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="13" BorderThickness="1" BorderBrush="Black">
                                                    </Border>
                                                    <Border Grid.Row="4" Grid.Column="0" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="3" Grid.Column="1"  Text=""  HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="4" Grid.Column="1" BorderThickness="1" BorderBrush="Black">
                                                        <TextBlock Grid.Row="3" Grid.Column="2"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                    </Border>
                                                    <Border Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="Black">
                                                        <StackPanel Orientation="Horizontal">
                                                            <TextBlock Grid.Row="4" Grid.Column="2"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                            <TextBlock Grid.Row="3" Grid.Column="4"  Text="" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                                        </StackPanel>
                                                    </Border>
                                                </Grid>
                                            </telerik:GridViewDataColumn.Header>
                                            <telerik:GridViewDataColumn.CellTemplate>
                                                <DataTemplate>
                                                    <Grid >
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="20"/>
                                                        </Grid.RowDefinitions>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="85"/>
                                                            <ColumnDefinition Width="85"/>
                                                            <ColumnDefinition Width="18"/>
                                                            <ColumnDefinition Width="55"/>
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Grid.Row="0" Grid.Column="0"  Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        <TextBlock Grid.Row="0" Grid.Column="1"  Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                        <Image Source="" Width="15" Height="15" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center"></Image>
                                                        <TextBlock Grid.Row="0" Grid.Column="3"  Text="" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                                    </Grid>
                                                </DataTemplate>
                                            </telerik:GridViewDataColumn.CellTemplate>
                                        </telerik:GridViewDataColumn>
                                    </telerik:RadGridView.Columns>
                                </telerik:RadGridView>

    the following code in xaml.cs

    //Headers

                var headers = GridViewSellIn.ChildrenOfType<TextBlock>();

                //GridViewSellThru.

                //foreach (var header in headers)
                //{
                //if (header.Name == "tbx1")
                //{
                //    if (App.MTDRatio != "")
                //        header.Text = "MTD (Target " + App.MTDRatio+ "%)";

                //}
                //if (header.Name == "tbx2")
                //{
                //    if (App.QTDRatio != "")
                //        header.Text = "QTD (Target " + App.QRatio + "%)";

                //}

                //if (header.Name == "tbx3")
                //{
                //    //DateTime ReportDate = DateTime.ParseExact(DrpDwnReportDate.SelectedValue.ToString(), "MM-dd-yyyy", CultureInfo.InvariantCulture);
                //    // DateTime ReportDate = DateTime.ParseExact(DrpDwnReportDate.SelectedValue,"MMddyyyy", CultureInfo.InvariantCulture);

                //    DateTime ReportDate = Convert.ToDateTime(DrpDwnReportDate.SelectedValue);
                //    //DateTime ReportDate = Convert.ToDateTime("2012 / 11 / 16");

                //    string strTimeStamp = String.Format("{0:MMM d, yyyy}", ReportDate);

                //    header.Text = App.SelAreaName+ " " + " Summary" + "-" + strTimeStamp;

                //}

                //if (header.Name == "TbxSellInQuarterHeader")
                //{
                //    header.Text = DrpDwnFiscalMonth.SelectedValue.ToString();
                //}

                tbx1.Text = "MTD (Target " + App.MTDRatioSellThru + "%)";
                tbx2.Text = "QTD (Target " + App.QTDRatioSellThru + "%)";

                DateTime ReportDate = Convert.ToDateTime(DrpDwnReportDate.SelectedValue);
                //DateTime ReportDate = Convert.ToDateTime("2012 / 11 / 16");

                string strTimeStamp = String.Format("{0:MMM d, yyyy}", ReportDate);

                tbx3.Text = App.SelAreaNameSellThru + " " + "WW Weekly Sellin Summary" + "-" + strTimeStamp;

                tbx4.Text = DrpDwnFiscalMonth.SelectedValue.ToString();

                //}

    Please provide me any solution

    Thanks
    Dinesh
Back to Top