【问题标题】:How to change data context and re-render single RadGridRow如何更改数据上下文并重新渲染单个 RadGridRow
【发布时间】:2010-07-23 11:49:06
【问题描述】:

After rendering full grid I need to change data context of selected Row since initially "simple" objects are filled as data source and when single item is selected (looking at RowDetailsVisibilityChanged event), then I want to change DataContext to complex object,这显示了比折叠行更多的详细信息。

使用 GridViewRowDetailsEventArgs.DetailsElement.DataContext 似乎可以解决在选择时在行下方展开的详细信息元素,但标题(列)保持不变,并且在更改 GridViewRowDetailsEventArgs.DetailsElement.DataContext 或 GridViewRowDetailsEventArgs.Row 时不会更新值。数据上下文。

(想象一下折叠行的列绑定到名称,其中名称为“John”,展开时,Row.DataContext 更改为属性名称为“John Dough”的对象,但列仍显示“John” )。

【问题讨论】:

    标签: silverlight telerik datacontext radgrid radgridview


    【解决方案1】:

    好的,我找到了一个解决方案,而且看起来很简单。

    所以...您将事件处理程序连接到 RadGridView.RowDetailsVisibilityChanged 并在事件处理程序本身中更改提供的行的 Item 属性:

    private void OnRowDetailsVisibilityChanged(object sender, GridViewRowDetailsEventArgs e)
    {
           e.Row.Item = (my New Data);
    }
    

    现在唯一的问题是该行不再是可点击的(选择它时详细信息不再展开)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-10
      • 2023-01-10
      • 2022-11-02
      • 1970-01-01
      • 2021-01-01
      • 2019-07-16
      • 1970-01-01
      • 2020-04-23
      相关资源
      最近更新 更多