应用 RowFilter 后隐藏没有可见子行的 UltragridRow

发布于 2024-11-24 07:52:41 字数 1550 浏览 2 评论 0原文

因此,我将 BindingSource 的 DataSource 设置为具有 DataRelation 的 DataSet 的 DefaultViewManager。然后,我将 BindingSource 设置为 UltraGrid 的数据源,然后将 RowFilter 应用于“SalesOrderSublines”DataView。

public void RefreshData()
{
   var dataset = DataService.GetMillWorkOrders()
   bindingSource1.DataSource = dataset.DefaultViewManager;
   ultraGridSequences.SetDataBinding(bindingSource1, "", true, true);

   var dvm = bindingSource1.DataSource as DataViewManager;

   dvm.DataViewSettings["SalesOrderSublines"].RowFilter = "LINE_NO = 2;
}

public static DataSet GetMillWorkOrders()
{
   DataSet ds = OracleHelper.ExecuteDataset(_connectionString,        CommandType.StoredProcedure, SQL.GET_WORK_ORDERS);

   ds.Tables[0].TableName = "WorkOrders";
   ds.Tables[1].TableName = "SalesOrderSublines";
   var dr = new DataRelation("WorkOrderSublines", ds.Tables["WorkOrders"].Columns["WORK_ORDER"], ds.Tables["SalesOrderSublines"].Columns["WORK_ORDER"]);
   ds.Relations.Add(dr);

   return ds;
}

然后,当 UltraGridRows 初始化时,我想隐藏由于我的 RowFilter 而没有可见子行(“WorkOrderSublines”)的任何父行(“WorkOrders”)。

private void ultraGridSequences_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
    if (e.Row.Band.Key != "WorkOrders") return;

    e.Row.Hidden = e.Row.ChildBands["WorkOrderSublines"].Rows.VisibleRowCount == 0;
}

尽管 RowFilter 确实在“WorkOrderSublines”区域中的行上正常工作,但该区域的 VisibleRowCount 仍然大于零,因此父行永远不会隐藏。我的猜测是,我想寻找 ChildBand 的 VisibleRowCount 以外的其他内容来确定是否应隐藏顶级行,但我被困住了。任何帮助将不胜感激。提前致谢。

So, I am setting the DataSource of my BindingSource to the DefaultViewManager of a DataSet that has a DataRelation. I then set my BindingSource as the UltraGrid's DataSource before applying a RowFilter to the the "SalesOrderSublines" DataView.

public void RefreshData()
{
   var dataset = DataService.GetMillWorkOrders()
   bindingSource1.DataSource = dataset.DefaultViewManager;
   ultraGridSequences.SetDataBinding(bindingSource1, "", true, true);

   var dvm = bindingSource1.DataSource as DataViewManager;

   dvm.DataViewSettings["SalesOrderSublines"].RowFilter = "LINE_NO = 2;
}

public static DataSet GetMillWorkOrders()
{
   DataSet ds = OracleHelper.ExecuteDataset(_connectionString,        CommandType.StoredProcedure, SQL.GET_WORK_ORDERS);

   ds.Tables[0].TableName = "WorkOrders";
   ds.Tables[1].TableName = "SalesOrderSublines";
   var dr = new DataRelation("WorkOrderSublines", ds.Tables["WorkOrders"].Columns["WORK_ORDER"], ds.Tables["SalesOrderSublines"].Columns["WORK_ORDER"]);
   ds.Relations.Add(dr);

   return ds;
}

Then, as the UltraGridRows are initializing I want to hide any parent row ("WorkOrders") that has no visible child rows ("WorkOrderSublines") because of my RowFilter.

private void ultraGridSequences_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
    if (e.Row.Band.Key != "WorkOrders") return;

    e.Row.Hidden = e.Row.ChildBands["WorkOrderSublines"].Rows.VisibleRowCount == 0;
}

Although the RowFilter does work properly on the rows in the "WorkOrderSublines" band the VisibleRowCount of the band is still greater than zero and so the parent row is never hidden. My guess is that I want to look for something other than the VisibleRowCount of the ChildBand to determine if the top-level row should be hidden, but I'm stuck. Any help would be greatly appreciated. Thanks ahead of time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风铃鹿 2024-12-01 07:52:41

您可以简单地比较已过滤的子行计数与总计数,而不是依赖 VisibleRowCount

void ultraGridSequences_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
    if (e.Row.Band.Key != "WorkOrders") return;
    var sublinesBand = e.Row.ChildBands["WorkOrderSublines"] 
    e.Row.Hidden = sublinesBand.Rows.Count(row => row.IsFilteredOut) ==
                    sublinesBand.Rows.Count();
}

只要我们不谈论大量记录,性能就应该很好吗?

Instead of relying on VisibleRowCount you could simply compare the count of child row filtered vs total count.

void ultraGridSequences_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
{
    if (e.Row.Band.Key != "WorkOrders") return;
    var sublinesBand = e.Row.ChildBands["WorkOrderSublines"] 
    e.Row.Hidden = sublinesBand.Rows.Count(row => row.IsFilteredOut) ==
                    sublinesBand.Rows.Count();
}

Should be fine performance-wise so long as we're not talking huge amounts of records?

宣告ˉ结束 2024-12-01 07:52:41

在网格中使用过滤可能是一种选择,而不是在数据源中使用过滤。以下资源提供了有关实现此功能的更多详细信息:

http://forums.infragistics.com/forums /t/51892.aspx

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7703

Using the Filtering within the Grid may be an option rather than using the filtering in the DataSource. The following resources have more details on implementing this:

http://forums.infragistics.com/forums/t/51892.aspx

http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7703

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文