开发者

Maintaining cell state in the Telerik RadGridView for Silverlight

开发者 https://www.devze.com 2022-12-27 16:27 出处:网络
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

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?


You can use the approach demonstrated in this blog post.

0

精彩评论

暂无评论...
验证码 换一张
取 消