如何更改数据上下文并重新渲染单个 RadGridRow
渲染完整网格后,我需要更改所选行的数据上下文,因为最初“简单”对象被填充为数据源,并且当选择单个项目时(查看 RowDetailsVisibilityChanged 事件),然后我想将 DataContext 更改为复杂对象,这显示了很多详细信息比折叠行更多。
使用 GridViewRowDetailsEventArgs.DetailsElement.DataContext 似乎可以解决在选择时在行下方展开的详细信息元素的技巧,但标题(列)保持不变,并且在更改 GridViewRowDetailsEventArgs.DetailsElement.DataContext 或 GridViewRowDetailsEventArgs.Row.DataCOntext 时不会更新值。
(想象一下,折叠行的列绑定到名称,其中名称为“John”,展开时,Row.DataContext 更改为属性名称为“John Dough”的对象,但列仍显示“John”)。
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, that shows much more info in details than in collapsed row.
Using GridViewRowDetailsEventArgs.DetailsElement.DataContext seems to do the trick for Details element that is expanded below row on selecting, BUT Header (Columns) stay the same and values are not updated when changing GridViewRowDetailsEventArgs.DetailsElement.DataContext or GridViewRowDetailsEventArgs.Row.DataCOntext .
(Imagine like column of collapsed row is bound to Name, where Name is "John", and when expanding, Row.DataContext is changed to to object with property Name with "John Dough", but column still shows "John").
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我找到了一个解决方案,它似乎非常简单。
所以...您将事件处理程序连接到 RadGridView.RowDetailsVisibilityChanged 并在事件处理程序本身中更改提供的行的 Item 属性:
现在唯一的问题是该行不再可单击(选择它时详细信息不再展开)。
Ok i found a solution and it seems to be pretty simple.
so ... you hook up event handler to RadGridView.RowDetailsVisibilityChanged and in event handler itself you change Item property of provided Row:
Only problem right now is that row is no longer clickable (details no longer expands when selecting it).