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

RowLoaded find cell by name

2 Answers 374 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 1
Veteran
Iron
Fredrik asked on 07 May 2020, 07:58 AM

I would like to find the cell from the name instead of the index. Is it possible?

<telerik:RadGridView ItemsSource="{Binding Tests}"
                                 AutoGenerateColumns="False"
                                 RowLoaded="RadGridView_RowLoaded">
                <telerik:RadGridView.Columns>
                    <telerik:GridViewToggleRowDetailsColumn />
                    <telerik:GridViewDataColumn Header="Title" DataMemberBinding="{Binding Title}" Name="Title" />

                    <telerik:GridViewDataColumn Header="Skapad" DataMemberBinding="{Binding Created}" Name="Modified" />

                </telerik:RadGridView.Columns>

 

 

private void RadGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
        {
            if (e.Row is Telerik.Windows.Controls.GridView.GridViewRow)
            {
                if (e.DataElement != null)
                {
                    ClearIfDefaultDate(e.Row.Cells[2].Content as TextBlock);
                }
            }
        }

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 12 May 2020, 06:27 AM

Hello Fredrik,

Thank you for the provided code snippet.

You can use the Column property of the cell to get a specific cell. Check the following code snippet.

private void GridView_RowLoaded(object sender, RowLoadedEventArgs e)
{
    if (e.Row is GridViewRow)
    {
        if(e.DataElement != null)
        {
            foreach (GridViewCell cell in e.Row.Cells)
            {
                if(cell.Column.Name == "Date")
                {
                    // your logic
                }
            }
        }
    }
}

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Fredrik
Top achievements
Rank 1
Veteran
Iron
answered on 12 May 2020, 06:31 AM
Ok, thank you!
Tags
GridView
Asked by
Fredrik
Top achievements
Rank 1
Veteran
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Fredrik
Top achievements
Rank 1
Veteran
Iron
Share this question
or