コード例 #1
0
        // Method to initialize the CaptionSummaryCell.

        public override void OnInitializeEditElement(DataColumnBase dataColumn, GridCaptionSummaryCell uiElement, object dataContext)
        {
            GridColumn column = dataColumn.GridColumn;

            if (dataContext is Group)
            {
                var groupRecord = dataContext as Group;
                if (this.DataGrid.CaptionSummaryRow == null)
                {
                    // get the column which is grouped
                    var groupedColumn = this.GetGroupedColumn(groupRecord);
                    //set the captionsummarycell text as customized.
                    uiElement.Content = GetCustomizedCaptionText(groupedColumn.HeaderText, groupRecord.Key,
                                                                 groupRecord.ItemsCount);
                }
                else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails,
                                                                                   this.DataGrid.View);
                }
                else
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails,
                                                                             column.MappingName, this.DataGrid.View);
                }
            }
        }
コード例 #2
0
        // Method to update the CaptionSummaryCell

        public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridCaptionSummaryCell element, object dataContext)
        {
            GridColumn column = dataColumn.GridColumn;

            if (element.DataContext is Group && this.DataGrid.View.GroupDescriptions.Count > 0)
            {
                var groupRecord = element.DataContext as Group;
                //get the column which is grouped.
                var groupedColumn = this.GetGroupedColumn(groupRecord);
                if (this.DataGrid.CaptionSummaryRow == null)
                {
                    if (this.DataGrid.View.GroupDescriptions.Count < groupRecord.Level)
                    {
                        return;
                    }
                    //set the captionsummary text as customized.
                    element.Content = GetCustomizedCaptionText(groupedColumn.HeaderText, groupRecord.Key,
                                                               groupRecord.ItemsCount);
                }
                else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    element.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails,
                                                                                 this.DataGrid.View, groupedColumn.HeaderText);
                }
                else
                {
                    element.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails,
                                                                           column.MappingName, this.DataGrid.View);
                }
            }
        }
コード例 #3
0
        public override void OnInitializeEditElement(DataColumnBase dataColumn, GridCaptionSummaryCell uiElement, object dataContext)
        {
            GridColumn column = dataColumn.GridColumn;

            if (dataContext is Group)
            {
                var groupRecord = dataContext as Group;
                if (this.DataGrid.CaptionSummaryRow == null)
                {
                    var groupedColumn = this.GetGroupedColumn(groupRecord);

                    //WPF-20212 - If we add the column in GroupColumnDescription which is not placed in SfDataGrid column collections, skipped here to group by that column.
                    ColumnGroupDescription groupDesc = null;
                    if (groupedColumn == null)
                    {
                        groupDesc = this.DataGrid.View.GroupDescriptions[groupRecord.Level - 1] as ColumnGroupDescription;
                        if (groupDesc == null)
                        {
                            return;
                        }
                    }
                    string stringFormat = this.DataGrid.GroupCaptionTextFormat ?? this.DataGrid.GroupCaptionConstant;
                    var    headerText   = groupedColumn != null ? groupedColumn.HeaderText : groupDesc.PropertyName;
                    uiElement.Content = this.DataGrid.View.TopLevelGroup.GetGroupCaptionText(groupRecord, stringFormat, headerText);
                }
                else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails, this.DataGrid.View);
                }
                else
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, column.MappingName, this.DataGrid.View);
                }
            }
        }
コード例 #4
0
        public override void UpdateToolTip(DataColumnBase dataColumn)
        {
            base.UpdateToolTip(dataColumn);
            var     uiElement = dataColumn.ColumnElement;
            var     column    = dataColumn.GridColumn;
            var     group     = dataColumn.ColumnElement.DataContext as Group;
            var     obj       = ToolTipService.GetToolTip(uiElement);
            ToolTip tooltip;

            if (obj is ToolTip)
            {
                tooltip = obj as ToolTip;
            }
            else
            {
                tooltip = new ToolTip();
            }

            var summaryColumns  = group.SummaryDetails.SummaryRow.SummaryColumns;
            var isSummaryColumn = summaryColumns.Any(col => col.MappingName == column.MappingName);

            if (isSummaryColumn)
            {
                tooltip.Content = SummaryCreator.GetSummaryDisplayText(group.SummaryDetails,
                                                                       dataColumn.GridColumn.MappingName, this.DataGrid.View);
                ToolTipService.SetToolTip(uiElement, tooltip);
            }
        }
        private void button1_Click(object sender, System.EventArgs e)
        {
            //var summary = this.sfDataGrid.View.Records.TableSummaries[0];
            //var value = SummaryCreator.GetSummaryDisplayTextForRow(summary, this.sfDataGrid.View);
            //MessageBox.Show(value);

            var summary = this.sfDataGrid.View.Records.TableSummaries[0];
            //Retrieves the summary row value of the Quantity column.
            var value = SummaryCreator.GetSummaryDisplayText(summary, "Quantity", this.sfDataGrid.View);

            MessageBox.Show(value);
        }
コード例 #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var data = value != null ? value as SummaryRecordEntry : null;

            if (data != null)
            {
                SfDataGrid dataGrid    = (SfDataGrid)parameter;
                var        summaryText = SummaryCreator.GetSummaryDisplayText(data, "qprogr01", dataGrid.View);

                return(summaryText.ToString());
            }

            return(null);
        }
コード例 #7
0
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var data = value != null ? value as SummaryRecordEntry : null;

            if (data != null)
            {
                SfDataGrid dataGrid  = (SfDataGrid)parameter;
                var        unitPrice = SummaryCreator.GetSummaryDisplayText(data, "UnitPrice", dataGrid.View);
                var        count     = SummaryCreator.GetSummaryDisplayText(data, "OrderID", dataGrid.View);

                return("Total Price : " + unitPrice.ToString() + " for " + count.ToString() + " Products ");
            }

            return(null);
        }
コード例 #8
0
        public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridTableSummaryCell element, object dataContext)
        {
            GridColumn column = dataColumn.GridColumn;

            if (dataContext is SummaryRecordEntry)
            {
                var record = dataContext as SummaryRecordEntry;
                if (record.SummaryRow.ShowSummaryInRow)
                {
                    element.Content = SummaryCreator.GetSummaryDisplayTextForRow(record, this.DataGrid.View);
                }
                else
                {
                    element.Content = SummaryCreator.GetSummaryDisplayText(record, column.MappingName, this.DataGrid.View);
                }
            }
        }
コード例 #9
0
        public override void OnInitializeEditElement(DataColumnBase dataColumn, GridGroupSummaryCell uiElement, object dataContext)
        {
            GridColumn column = dataColumn.GridColumn;

            if (dataContext is SummaryRecordEntry)
            {
                var record = dataContext as SummaryRecordEntry;
                if (record.SummaryRow.ShowSummaryInRow)
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayTextForRow(record, this.DataGrid.View);
                }
                else
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayText(record, column.MappingName, this.DataGrid.View);
                }
            }
        }
        /// <summary>
        /// Method to update the CaptionSummaryCell
        /// </summary>
        public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridCaptionSummaryCell element, object dataContext)
        {
            if (element.DataContext is Group && this.DataGrid.View.GroupDescriptions.Count > 0)
            {
                string groupName   = string.Empty;
                string groupText   = string.Empty;
                var    groupRecord = element.DataContext as Group;
                //get the column which is grouped.
                var groupedColumn = this.GetGroupedColumn(groupRecord);

                var groupRecords = (groupRecord.Details as GroupRecordEntry).Records;
                var groupData    = (groupRecords[0] as RecordEntry).Data;

                if (groupedColumn.MappingName == "EmployeeID")
                {
                    groupName = (groupData as BusinessObject).EmployeeName;
                    groupText = "Employee Name";
                }
                else
                {
                    groupName = groupRecord.Key.ToString();
                    groupText = groupedColumn.HeaderText;
                }
                if (this.DataGrid.CaptionSummaryRow == null)
                {
                    if (this.DataGrid.View.GroupDescriptions.Count < groupRecord.Level)
                    {
                        return;
                    }
                    //set the captionsummary text as customized.
                    element.Content = GetCustomizedCaptionText(groupText, groupName, groupRecord.ItemsCount);
                }
                else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    element.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails, this.DataGrid.View, groupedColumn.HeaderText);
                }
                else
                {
                    element.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, dataColumn.GridColumn.MappingName, this.DataGrid.View);
                }
            }
        }
コード例 #11
0
 public override void OnInitializeEditElement(DataColumnBase dataColumn, GridCaptionSummaryCell uiElement, object dataContext)
 {
     if (dataContext is Group)
     {
         var groupRecord = dataContext as Group;
         if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
         {
             uiElement.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails,
                                                                            this.DataGrid.View);
         }
         else
         {
             uiElement.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails,
                                                                      dataColumn.GridColumn.MappingName, this.DataGrid.View);
             if (uiElement.Content == (object)"" && dataColumn.GridColumn.MappingName == "EmployeeName")//&& this.DataGrid.GroupColumnDescriptions.Any(col => col.ColumnName == dataColumn.GridColumn.MappingName))
             {
                 uiElement.Content = groupRecord.Key;
             }
         }
     }
 }
コード例 #12
0
        public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridCaptionSummaryCell element, object dataContext)
        {
            GridColumn column = dataColumn.GridColumn;

            if (element.DataContext is Group && this.DataGrid.View.GroupDescriptions.Count > 0)
            {
                var groupRecord   = element.DataContext as Group;
                var groupedColumn = this.GetGroupedColumn(groupRecord);

                ColumnGroupDescription groupDesc = null;
                //WPF-20212 - If we add the column in GroupColumnDescription which is not placed in SfDataGrid column collections, skipped here to group by that column.
                if (groupedColumn == null)
                {
                    groupDesc = this.DataGrid.View.GroupDescriptions[groupRecord.Level - 1] as ColumnGroupDescription;
                    if (groupDesc == null)
                    {
                        return;
                    }
                }
                // WPF-36158 When we defined GroupColumnDescription column name are not mentioned in SfGrid columns. So the header text are not applied to summary rows.
                var headerText = groupedColumn != null ? groupedColumn.HeaderText : groupDesc.PropertyName;
                if (this.DataGrid.CaptionSummaryRow == null)
                {
                    if (this.DataGrid.View.GroupDescriptions.Count < groupRecord.Level)
                    {
                        return;
                    }
                    var stringFormat = this.DataGrid.GroupCaptionTextFormat ?? this.DataGrid.GroupCaptionConstant;
                    element.Content = this.DataGrid.View.TopLevelGroup.GetGroupCaptionText(groupRecord, stringFormat, headerText);
                }
                else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    element.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails, this.DataGrid.View, headerText);
                }
                else
                {
                    element.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, column.MappingName, this.DataGrid.View);
                }
            }
        }
        /// <summary>
        /// Method to initialize the CaptionSummaryCell.
        /// </summary>
        public override void OnInitializeEditElement(DataColumnBase dataColumn, GridCaptionSummaryCell uiElement, object dataContext)
        {
            if (dataContext is Group)
            {
                string groupName   = string.Empty;
                var    groupRecord = dataContext as Group;
                if (this.DataGrid.CaptionSummaryRow == null)
                {
                    // get the column which is grouped
                    var groupedColumn = this.GetGroupedColumn(groupRecord);
                    //set the captionsummarycell text as customized.

                    var groupRecords = (groupRecord.Details as GroupRecordEntry).Records;
                    var groupData    = (groupRecords[0] as RecordEntry).Data;

                    if (groupedColumn.MappingName == "EmployeeID")
                    {
                        groupName = (groupData as BusinessObject).EmployeeName;
                    }
                    else
                    {
                        groupName = groupRecord.Key.ToString();
                    }

                    uiElement.Content = GetCustomizedCaptionText(groupedColumn.HeaderText, groupName, groupRecord.ItemsCount);
                }
                else if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails, this.DataGrid.View);
                }
                else
                {
                    uiElement.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails, dataColumn.GridColumn.MappingName, this.DataGrid.View);
                }
            }
        }
コード例 #14
0
        public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridCaptionSummaryCell element, object dataContext)
        {
            if (element.DataContext is Group && this.DataGrid.View.GroupDescriptions.Count > 0)
            {
                var groupRecord = element.DataContext as Group;
                //get the column which is grouped.
                var groupedColumn = this.GetGroupedColumn(groupRecord);
                if (this.DataGrid.CaptionSummaryRow.ShowSummaryInRow)
                {
                    element.Content = SummaryCreator.GetSummaryDisplayTextForRow(groupRecord.SummaryDetails,
                                                                                 this.DataGrid.View, groupedColumn.HeaderText);
                }
                else
                {
                    element.Content = SummaryCreator.GetSummaryDisplayText(groupRecord.SummaryDetails,
                                                                           dataColumn.GridColumn.MappingName, this.DataGrid.View);

                    if (element.Content == (object)"" && dataColumn.GridColumn.MappingName == this.DataGrid.Columns.FirstOrDefault(col => !col.IsHidden).MappingName)
                    {
                        element.Content = groupRecord.Key;
                    }
                }
            }
        }
        protected override void AddCaptionSummaryRowToPanel(PrintPagePanel panel, RowInfo rowInfo)
        {
            base.AddCaptionSummaryRowToPanel(panel, rowInfo);
            var cellsInfo       = rowInfo.CellsInfo;
            var topThickNess    = rowInfo.NeedTopBorder ? 1 : 0;
            var bottomThickness = rowInfo.NeedBottomBorder ? 1 : 0;
            var group           = rowInfo.Record as Group;

            for (var start = 0; start < cellsInfo.Count; start++)
            {
                var cellInfo = cellsInfo[start];
                if (IsCaptionSummaryInRow)
                {
                    var cell = GetPrintCaptionSummaryCell(group, cellInfo.ColumnName);
                    cell.FlowDirection   = PrintFlowDirection;
                    cell.Width           = cellInfo.CellRect.Width;
                    cell.Padding         = new Thickness(2, 0, 0, 0);
                    cell.BorderThickness = new Thickness(1, topThickNess, 1, bottomThickness);
                    cell.Content         = new TextBlock
                    {
                        Text =
                            View.TopLevelGroup.GetGroupCaptionText(group,
                                                                   GetGroupCaptionStringFormat
                                                                       (), cellInfo.ColumnName),
                        HorizontalAlignment = HorizontalAlignment.Left,
                        VerticalAlignment   = VerticalAlignment.Center
                    };

                    cellInfo.Element = cell;
                    panel.Children.Add(cell);
                }
                else
                {
                    var cell = GetPrintCaptionSummaryCell(group, cellInfo.ColumnName);
                    cell.FlowDirection = PrintFlowDirection;
                    cell.Width         = cellInfo.CellRect.Width;
                    cell.Padding       = new Thickness(2, 0, 0, 0);

                    //Setting grid lines for PrintCaptionSummaryCell.
                    if (start == 0)
                    {
                        cell.BorderThickness = new Thickness(1, topThickNess, 1, bottomThickness);
                    }
                    else
                    {
                        cell.BorderThickness = new Thickness(0, topThickNess, 1, bottomThickness);
                    }

                    var summaryColumns = group.SummaryDetails.SummaryRow.SummaryColumns;
                    if (summaryColumns != null && summaryColumns.Any())
                    {
                        var textBlock = new TextBlock
                        {
                            Padding             = new Thickness(2, 0, 0, 0),
                            HorizontalAlignment = HorizontalAlignment.Right,
                            VerticalAlignment   = VerticalAlignment.Center,
                        };

                        //Setting value for PrintCaptionSummaryCell.
                        if (summaryColumns.Any(x => x.MappingName == cellInfo.ColumnName))
                        {
                            textBlock.Text = SummaryCreator.GetSummaryDisplayText(group.SummaryDetails, cellInfo.ColumnName, View);
                        }
                        else if (cellInfo.ColumnName == "EmployeeName")
                        {
                            textBlock.Text = group.Key.ToString();
                        }

                        cell.Content     = textBlock;
                        cellInfo.Element = cell;
                        panel.Children.Add(cell);
                    }
                }
            }
        }