static private BuildRows ( List |
||
cellPlaceholderListsForRows | List |
|
rowSetups | IReadOnlyList |
|
useContrastForFirstRow | bool | |
columns | IReadOnlyList |
|
firstDataColumnIndex | int | |
tableIsColumnPrimary | bool | |
return | IEnumerable |
void ControlTreeDataLoader.LoadData() { if (hideIfEmpty && itemGroups.All(itemGroup => !itemGroup.Items.Any())) { Visible = false; return; } EwfTable.SetUpTableAndCaption(this, style, classes, caption, subCaption); var itemSetupLists = new[] { headItems }.Concat(itemGroups.Select(i => i.Items)).Select(i => i.Select(j => j.Setup.FieldOrItemSetup)); var allItemSetups = itemSetupLists.SelectMany(i => i).ToImmutableArray(); var columnWidthFactor = EwfTable.GetColumnWidthFactor(allItemSetups); foreach (var itemSetups in itemSetupLists.Where(i => i.Any())) { Controls.Add( new WebControl(HtmlTextWriterTag.Colgroup).AddControlsReturnThis(itemSetups.Select(i => EwfTable.GetColControl(i, columnWidthFactor)))); } var fields = EwfTable.GetFields(specifiedFields, headItems, itemGroups.SelectMany(i => i.Items)); var cellPlaceholderListsForItems = TableOps.BuildCellPlaceholderListsForItems( headItems.Concat(itemGroups.SelectMany(i => i.Items)).ToList(), fields.Count); // Pivot the cell placeholders from column primary into row primary format. var cellPlaceholderListsForRows = Enumerable.Range(0, fields.Count) .Select(field => Enumerable.Range(0, allItemSetups.Length).Select(item => cellPlaceholderListsForItems[item][field]).ToList()) .ToList(); var headRows = TableOps.BuildRows( cellPlaceholderListsForRows.Take(firstDataFieldIndex).ToList(), fields.Select(i => i.FieldOrItemSetup).ToImmutableArray(), null, allItemSetups, allItemSetups.Length, true); var bodyRows = TableOps.BuildRows( cellPlaceholderListsForRows.Skip(firstDataFieldIndex).ToList(), fields.Select(i => i.FieldOrItemSetup).ToImmutableArray(), false, allItemSetups, headItems.Count, true); // We can't easily put the head fields in thead because we don't have a way of verifying that cells don't cross between head and data fields. Controls.Add(new WebControl(HtmlTextWriterTag.Tbody).AddControlsReturnThis(headRows.Concat(bodyRows))); EwfTable.AssertAtLeastOneCellPerField(fields, cellPlaceholderListsForItems); }
private IEnumerable <Control> buildRows( IReadOnlyCollection <EwfTableItem> items, IReadOnlyCollection <EwfTableField> fields, bool?useContrastForFirstRow, bool useHeadCells, Func <EwfTableCell> itemActionCheckBoxCellGetter, Func <EwfTableCell> itemReorderingCellGetter, List <EwfTableItem> allVisibleItems) { // Assert that the cells in the list of items are valid and store a data structure for below. var cellPlaceholderListsForRows = TableOps.BuildCellPlaceholderListsForItems(items, fields.Count); // NOTE: Be sure to take check box and reordering columns into account. var rows = TableOps.BuildRows( cellPlaceholderListsForRows, items.Select(i => i.Setup.FieldOrItemSetup).ToImmutableArray(), useContrastForFirstRow, fields.Select(i => i.FieldOrItemSetup).ToImmutableArray(), useHeadCells ? fields.Count : 0, false); allVisibleItems.AddRange(items); return(rows); }