0

因此,我將我的BindingSource的DataSource設置爲具有DataRelation的DataSet的DefaultViewManager。然後,在將RowFilter應用於「SalesOrderSublines」DataView之前,我將BindingSource設置爲UltraGrid的DataSource。隱藏應用RowFilter後沒有可見子行的UltragridRow

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」)的任何父行(「工作訂單」)。

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以外的其他內容,以確定頂層行是否應該隱藏,但我被卡住了。任何幫助將不勝感激。提前致謝。

回答

0

而不是依靠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(); 
} 

只要我們沒有說大量的記錄,應該是好的表現方式?

相關問題