【问题标题】:Maintaining cell state in the Telerik RadGridView for Silverlight在 Telerik RadGridView for Silverlight 中维护单元格状态
【发布时间】:2010-04-19 21:06:08
【问题描述】:

我有一个 RadGridView,其中一列只包含按钮。

根据链接到网格中特定记录的布尔变量的值,我启用或禁用包含按钮的单元格。这就是我实现这一目标的方式:

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;
            }
        }
    }
}

问题是因为我的网格有水平和垂直滚动条,而且由于我使用的是行和列虚拟化,所以包含未显示按钮的单元格的状态会丢失。就我而言,禁用虚拟化不是解决方案,因为我的网格中有很多数据。

我想知道 RadGridView 的哪个事件最适合调用我的函数,该函数在显示值发生变化时设置按钮单元格的状态?

【问题讨论】:

    标签: c# silverlight telerik


    【解决方案1】:

    您可以使用this blog post 中演示的方法。

    【讨论】:

    • 谢谢弗拉德。事实上,当我垂直滚动时,使用 RowLoaded 事件可以完成这项工作。但是,对于水平滚动,我找不到像“ColumnLoaded”这样的等效事件。有什么想法吗?
    • 这个想法是使用 IValueConverter 代替,如我之前回复的博客文章中所示。这将按预期与列和行虚拟化一起工作。此外,最近我们为网格引入了样式和模板选择器,您也可以使用它们来实现您的目标。您可以查看我的博客文章了解更多信息:blogs.telerik.com/vladimirenchev/posts/10-04-01/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    • 2011-05-02
    • 2013-01-27
    • 1970-01-01
    相关资源
    最近更新 更多