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

Help ! RadGridView CellTemplate ChildrenOfType not running :-(

4 Answers 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
EBIS EBIS
Top achievements
Rank 1
EBIS EBIS asked on 01 Jan 2012, 10:12 PM

Hi.I'am using Vs2010 and silverlight 5 and Telerik RadControls for Silverlight Q3 2011.
I downloaded  "01744RadControls_for_Silverlight5_2011_3_1227_DEV_hotfix"
When I search a control in the radgridview celltemplate but I can't see it.
like "cell.ChildrenOfType<RadButton>"
Please help

<telerik:GridViewColumn UniqueName="ButtonColumn">

                    <telerik:GridViewColumn.CellTemplate>

                        <DataTemplate>

                            <telerik:RadButton Content="Ba┼člat" Name="button1" Tag="{Binding}"  Click=" button1"/>

                        </DataTemplate>

                    </telerik:GridViewColumn.CellTemplate>

 </telerik:GridViewColumn>

private void RadGridView1_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)

 {

                var cell = e.Row.Cells.FirstOrDefault(c => c.Column.UniqueName == "ButtonColumn");

            if (cell != null)

            {

                var button = cell.ChildrenOfType<RadButton>().FirstOrDefault();

            }

 }

when I debuged button is null :-(


4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 02 Jan 2012, 10:28 AM
Hi,

I am not sure what is the final goal you are trying to achieve but you may try the following - subscribe to the loaded event to the button itself and execute your relevant code in the handler of the Loaded event of the button.

In case this is not applicable , please share some more info on what you are trying to achieve so we can find the best solution for your specific scenario.

All the best,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
EBIS EBIS
Top achievements
Rank 1
answered on 02 Jan 2012, 12:25 PM
thank you,
 it is no ok.
0
EBIS EBIS
Top achievements
Rank 1
answered on 03 Dec 2012, 08:43 AM
I'm sorry, No it is not.

My purpose is, inserting Button to RadGridView Row in runtime.It just;


private void AddColumnToGrid(){
              GridViewColumn clmn = new GridViewColumn();
                TelerikDataGrid.Columns.Insert(0, clmn);
}


public void TelerikDataGrid_RowLoaded(object sender, RowLoadedEventArgs e)
        {

if (!e.Row.GetType().Equals(typeof(GridViewHeaderRow)) && !e.Row.GetType().Equals(typeof(GridViewFooterRow)))
  {
                 StackPanel sb = new StackPanel();
                  sb.Orientation = Orientation.Horizontal;

                  RadButton btnEdit = null;
                  btnEdit = new RadButton();
                  btnEdit.Content = "Detail";
                  btnEdit.Click += new RoutedEventHandler(btnEdit_Click);
                  sb.Children.Add(btnEdit);

                       if (e.Row.Cells!=null&&e.Row.Cells.Count > 0)
                        {
                            e.Row.Cells[0].Content = sb;
                        }
  }
                 

}



btnEdit Button is not show in the Row :-(



0
Vlad
Telerik team
answered on 04 Dec 2012, 02:00 PM
Hello,

According to your reply almost a year ago the solution worked. Can you post more info what is changed?

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
EBIS EBIS
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
EBIS EBIS
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or