views:

522

answers:

1

I have a RadGridView in which one of the columns contains only buttons.

Depending on the value of a boolean variable linked to a specific record in the grid, I enable or disable the cell containing the button. This is how I achieve this:

foreach (Item item in this.radGridView.Items)
{
    row = this.radGridView.ItemContainerGenerator.ContainerFromItem(item) as GridViewRow;

    if (row != null)
    {
        cell = (from c in row.Cells
                where c.Column.UniqueName == "buttonCol"
                select c).FirstOrDefault();
        if (cell != null)
        {
            if (item.buttonEnabled)
            {
                cell.IsEnabled = true;
            }
            else
            {
                cell.IsEnabled = false;
            }
        }
    }
}

The problem is since my grid has horizontal and vertical scrollbars and since I am using row and column virtualization, the state of the cells containing the button that are not shown is lost. Disabling virtualization is not a solution in my case since I have a lot of data in my grid.

I wonder which event of the RadGridView would be the best to invoke my function that set the state of the button cells whenever shown values change?

A: 

You can use the approach demonstrated in this blog post.

Vlad
Thanks Vlad. Indeed, using the RowLoaded event does the job when I'm vertically scrolling. However, I cannot find an equivalent event like "ColumnLoaded" for the horizontal scrolling. Any ideas?
jbethier
The idea is to use IValueConverter instead as showed in the blog post from my previous reply. This will work as expected with both columns and rows virtualization. Furthermore recently we introduced Style and Template selectors for the grid and you can use them as well to achieve your goal. You can check my blog post for more info: http://blogs.telerik.com/vladimirenchev/posts/10-04-01/conditional_styles_and_templates_with_radgridview_for_silverlight_and_wpf.aspx
Vlad