当 ListChanged 时刷新 UltraGrid 的 GroupBy 对子带进行排序?
我正在使用 Infragistics 2009 第 1 卷。
我的 UltraGrid 绑定到业务对象“A”的 BindingList,该对象本身具有业务对象“B”的 BindingList 属性。 它导致有两个带:一个名为“BindingList`1”,另一个名为“ListOfB”,这要归功于货币管理器。
每当通过子业务对象和 INotifyPropertyChange 对子带执行更改时,我想刷新网格的 GroupBy 排序。
如果我按子带中的属性进行分组,该属性是布尔值(假设为“Active”),并且我使用此事件处理程序订阅绑定列表数据源上的事件 ListChanged:
void Grid_ListChanged(object sender, ListChangedEventArgs e)
{
if (e.ListChangedType == ListChangedType.ItemChanged)
{
string columnKey = e.PropertyDescriptor.Name;
if (e.PropertyDescriptor.PropertyType.Name == "BindingList`1")
{
ultraGrid.DisplayLayout.Bands[columnKey].SortedColumns.RefreshSort(true);
}
else
{
UltraGridBand band = ultraGrid.DisplayLayout.Bands[0];
UltraGridColumn gc = band.Columns[columnKey];
if (gc.IsGroupByColumn || gc.SortIndicator != SortIndicator.None)
{
band.SortedColumns.RefreshSort(true);
}
ColumnFilter cf = band.ColumnFilters[columnKey];
if (cf.FilterConditions.Count > 0)
{
ultraGrid.DisplayLayout.RefreshFilters();
}
}
}
}
调用 band.SortedColumns.RefreshSort(true) 但它当子带中的 Active 属性发生更改时,在 groupby 区域中会产生不可预测的结果:
如果三个活动对象中有一个对象变为非活动状态,则它会从:
- Active : True (3 项)
变为:
- Active : False (3 项)
而不是 (当我将列来回拖动到按区域分组时就是这种情况)
Active:False(1 项)
Active:True(2 项)< /p>
我做错了什么吗?
有没有办法在执行 RefreshSort(true); 时恢复行的展开状态? ?
I am using Infragistics 2009 vol 1.
My UltraGrid is bound to a BindingList of business objects "A" having themself a BindingList property of business objects "B". It results in having two bands: one named "BindingList`1", the other one "ListOfB" thanks to the currency manager.
I would like to refresh the GroupBy sort of the grid whenever a change is performed on the child band through the child business object and INotifyPropertyChange.
If I group by a property in the child band which is a boolean (let's say "Active") and I subscribe to the event ListChanged on the bindinglist datasource with this event handler:
void Grid_ListChanged(object sender, ListChangedEventArgs e)
{
if (e.ListChangedType == ListChangedType.ItemChanged)
{
string columnKey = e.PropertyDescriptor.Name;
if (e.PropertyDescriptor.PropertyType.Name == "BindingList`1")
{
ultraGrid.DisplayLayout.Bands[columnKey].SortedColumns.RefreshSort(true);
}
else
{
UltraGridBand band = ultraGrid.DisplayLayout.Bands[0];
UltraGridColumn gc = band.Columns[columnKey];
if (gc.IsGroupByColumn || gc.SortIndicator != SortIndicator.None)
{
band.SortedColumns.RefreshSort(true);
}
ColumnFilter cf = band.ColumnFilters[columnKey];
if (cf.FilterConditions.Count > 0)
{
ultraGrid.DisplayLayout.RefreshFilters();
}
}
}
}
the band.SortedColumns.RefreshSort(true) is called but It gives unpredictable results in the groupby area when the property Active is changed in the child band:
if one object out of three actives becomes inactive it goes from:
- Active : True (3 items)
To:
- Active : False (3 items)
Instead of (which is the case when I drag the column back and forth to the group by area)
Active : False (1 item)
Active : True (2 items)
Am I doing something wrong?
Is there a way to restore the expanded state of the rows when performing a RefreshSort(true); ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说听起来像是一个错误 - 你应该向 Infragistics 提交一个错误。
至于解决方法 - 这不是一个很好的解决方案,我还没有测试过它,但您始终可以尝试将排序(组)列保存到临时存储中,在带上使用 RefreshSort() ,然后重新应用排序-by(组)列,然后再次排序?
IE。 删除分组依据,然后重新应用。
令人讨厌,但它可能会让你摆脱困境。
Sounds like a bug to me - you should file one with Infragistics.
As to a workaround - this is not a nice solution and I haven't tested it but you could always try saving the sort-by (group) columns to a temp store, RefreshSort() on the band, then re-apply the sort-by (gorup) columns, and sort again?
ie. Remove group-by, then re-apply.
Nasty, but it might get you out of a bind.
好吧,这就是我解决问题的方法
这是包含信息的对象
Well, this is how I manage to solve the problem
And this is the object that contains the information