PdfRpt.Core.PdfTable.GroupsManager.ShouldStartNewGroup C# (CSharp) Method

ShouldStartNewGroup() public method

Should we start a new group based on the current row's data?
public ShouldStartNewGroup ( IList rowCellsData ) : bool
rowCellsData IList Current row's data
return bool
        public bool ShouldStartNewGroup(IList<CellData> rowCellsData)
        {
            if (!SharedData.IsGroupingEnabled) return false;

            if (CurrentRowInfoData.LastOverallDataRowNumber == 1)
            {
                updateLastRowValues(rowCellsData);
                return true;
            }

            foreach (var property in SharedData.GroupByProperties)
            {
                var currentCellValue = getCurrentCellValue(rowCellsData, property);
                object lastRowCellValue;
                if (_currentRowValues.TryGetValue(property, out lastRowCellValue))
                {
                    if (!areEqual(lastRowCellValue, currentCellValue, property))
                    {
                        _currentRowValues.Clear();
                        updateLastRowValues(rowCellsData);
                        return true;
                    }
                }
                else
                {
                    _currentRowValues.Add(new KeyValuePair<string, object>(property, currentCellValue));
                }
            }

            return false;
        }

Usage Example

コード例 #1
0
ファイル: RowsManager.cs プロジェクト: slledru/PdfReport
        private IList <BaseColor> applyRowSettings(IList <CellData> row)
        {
            if (_setNumberOfRowsPerPageNeedsNewPage)
            {
                SharedData.PdfDoc.NewPage();
            }

            var backColor = CurrentRowInfoData.LastOverallDataRowNumber % 2 != 0 ? SharedData.Template.RowBackgroundColor : SharedData.Template.AlternatingRowBackgroundColor;
            var foreColor = CurrentRowInfoData.LastOverallDataRowNumber % 2 != 0 ? SharedData.Template.RowFontColor : SharedData.Template.AlternatingRowFontColor;

            CurrentRowInfoData.LastOverallDataRowNumber++;
            CurrentRowInfoData.LastGroupRowNumber++;

            if (GroupsManager.ShouldStartNewGroup(row))
            {
                GroupsManager.StartNewGroup(row, !_setNumberOfRowsPerPageNeedsNewPage);
            }
            else
            {
                if (CurrentRowInfoData.LastOverallDataRowNumber == 1)
                {
                    TableInitAddHeaderAndFooter();
                }
            }

            return(new List <BaseColor> {
                backColor, foreColor
            });
        }