我有以下代碼來洗掉檢索 UI 事件的摘要行/帶值。我確定這是錯誤的方法,但它確實有效。
public UiEventResult AfterRetrieveData_111(object sender, RetrieveDataEventArgs e)
{
UltraGridBase baseGrid = _view.ViewGrids["ultraGrid1"];
UltraGridLayout gridLayout = baseGrid.DisplayLayout;
for (int i = 0; i < 2; i )
{
gridLayout.Bands[i].Columns["columnA"].Formula = "''";
}
for (int i = 0; i < 3; i )
{
gridLayout.Bands[i].Columns["columnB"].Formula = "''";
gridLayout.Bands[i].Columns["columnC"].Formula = "''";
}
有沒有辦法對檢索進行編程,以便填充 A/band[2] 列的摘要行,以便使用每列中的最后一個值?如果沒有上面的代碼,它將對下面的行求和,但希望有一種方法可以使用最后一行的值。資料將始終按日期按 DESC 排序,因此最后一行將始終是所需的值...

uj5u.com熱心網友回復:
實作此目的的一種方法是在InitializeRowEvent中,將 columnA 的值設定為子帶中最后一行的值,如下所示:
// Update the rows only in the first band. You can also use e.Row.Band.Key == {YOU_BAND_KEY}
if (e.Row.Band.Index == 0)
{
// set the value of the columnA to the value of the last row in the child band
e.Row.Cells["columnA"].Value = e.Row.ChildBands.LastRow.Cells["columnA"].Value;
}
請注意,如果您編輯單元格值,這將不起作用。如果您需要在單元格更新后更新父行值,請再次在 InitializeRowEvent 中添加:
// look for row in the secon band
if (e.Row.Band.Index == 1)
{
// get the last row in the second band
if (e.Row == e.Row.ParentRow.ChildBands.LastRow)
{
// get the value of the last row in the second band and set it to the parent row
e.Row.ParentRow.Cells["columnA"].Value = e.Row.Cells["columnA"].Value;
}
}
uj5u.com熱心網友回復:
這將遍歷 ChildBands 并使用每個 ChildBand 中的最后一個值設定父行值。
int rowCount = gridLayout.Rows.Count;
for (int i = 0; i < rowCount; i )
{
foreach (UltraGridChildBand childBand in baseGrid.Rows[i].ChildBands)
{
foreach (UltraGridRow row in childBand.Rows)
{
row.Cells["columnA"].Value =row.ChildBands.LastRow.Cells["columnA"].Value;
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/452590.html
上一篇:如何撰寫介面的輸入和輸出泛型引數
