private void xdgEDPatientsListMaximized_Sorted(object sender, Infragistics.Windows.DataPresenter.Events.SortedEventArgs e)
        {
            FieldSortDescription sortDescription = new FieldSortDescription()
            {
                FieldName = e.SortDescription.FieldName,
                IsGroupBy = false,
                Direction = e.SortDescription.Direction
            };

            this.xdgEDPatientsListNormal.FieldLayouts[0].SortedFields.Clear();
            this.xdgEDPatientsListNormal.FieldLayouts[0].SortedFields.Add(sortDescription);
        }
Beispiel #2
0
        static void SetValidateColumnsForXamDataGrid(XamDataGrid dataGrid, DataTableEx userTable)
        {
            var hierObjectStyle = dataGrid.FindResource("HierObjectStyle") as Style;
            var hTemplate       = dataGrid.FindResource("HierarchyObjectTemplate") as DataTemplate;
            var chTemplate      = dataGrid.FindResource("ChannelTemplate") as DataTemplate;
            var fFlagStyle      = dataGrid.FindResource("FFlagStyle") as Style;

            dataGrid.FieldSettings.LabelPresenterStyle = dataGrid.FindResource("ValidLabelStyle") as Style;
            // dataGrid.BeginInit();

            //var leftHorizontalStyle = dataGrid.FindResource("FastHorizontalLeftCellValuePresenterStyle") as Style;

            var fieldLayout = dataGrid.FieldLayouts[0];
            var fields      = fieldLayout.Fields;

            //var field = fieldLayout.Fields["NameTI"] as TemplateField;
            try
            {
                fields.BeginUpdate();

                #region Вспомогательные поля

                var comparer = new IFreeHierarchyObjectComparer();

                var tiFld = new Field
                {
                    Name          = "NameTI",
                    DataType      = typeof(IFreeHierarchyObject),
                    Label         = "Объект",
                    Width         = new FieldLength(200),
                    FixedLocation = FixedFieldLocation.FixedToNearEdge,
                    //FixedLocation = FixedFieldLocation.FixedToNearEdge,
                    Settings =
                    {
                        AllowGroupBy              = true,
                        GroupByComparer           = comparer,
                        SortComparer              = comparer,
                        FilterComparer            = comparer,
                        CellVisibilityWhenGrouped = Visibility.Collapsed,
                        FilterOperandUIType       = FilterOperandUIType.DropDownList,
                        AllowFixing             = AllowFieldFixing.Near,
                        AllowEdit               = false,
                        EditorStyle             = null,
                        AllowRecordFiltering    = true,
                        CellValuePresenterStyle = hierObjectStyle,
                    },
                    HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                };

                //if (leftHorizontalStyle != null)
                //{
                //    //Это
                //    tiFld.Settings.CellValuePresenterStyle = leftHorizontalStyle;
                //}

                fields.Add(tiFld);

                fields.Add(new TemplateField
                {
                    Name            = "Channel",
                    Label           = "К",
                    DataType        = typeof(object),
                    DisplayTemplate = chTemplate,
                    Width           = new FieldLength(30),
                    FixedLocation   = FixedFieldLocation.FixedToNearEdge,
                    Settings        = { FilterOperandUIType = FilterOperandUIType.None,
                                        AllowFixing         = AllowFieldFixing.Near,
                                        AllowEdit           = false,
                                        EditorStyle         = null, },
                });

                //fieldLayout.Fields.Add(new TemplateField
                //{
                //    Name = "DataSource",
                //    Label = "Источник данных",
                //    Width = new FieldLength(130),
                //});

                var fld = new Field
                {
                    Name        = "Parent",
                    DataType    = typeof(IFreeHierarchyObject),
                    Label       = "Родитель",
                    Width       = new FieldLength(160),
                    AllowFixing = AllowFieldFixing.Near,
                    //FixedLocation = FixedFieldLocation.FixedToNearEdge,
                    Settings =
                    {
                        //GroupByMode = FieldGroupByMode.Value,
                        AllowGroupBy              = true,
                        GroupByComparer           = comparer,
                        SortComparer              = comparer,
                        FilterComparer            = comparer,
                        CellVisibilityWhenGrouped = Visibility.Collapsed,
                        FilterOperandUIType       = FilterOperandUIType.DropDownList,
                        AllowFixing             = AllowFieldFixing.Near,
                        AllowEdit               = false,
                        EditorStyle             = null,
                        AllowRecordFiltering    = true,
                        CellValuePresenterStyle = hierObjectStyle,
                    },
                    HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left,
                    VerticalContentAlignment   = VerticalAlignment.Center,
                };

                fields.Add(fld);
                var fsd = new FieldSortDescription("Parent", ListSortDirection.Ascending, true);
                fieldLayout.SortedFields.Add(fsd);

                #endregion

                // var flagStyle = XamDataGridHelper.DataTemplateSelectorToCellEditorStyle(flagTemplateSelector, null);

                var width  = new FieldLength(32);
                var height = new FieldLength(20);

                foreach (DataColumn col in userTable.Columns)
                {
                    //var column = fieldLayout.Fields.FirstOrDefault(c => string.Equals(c.Name, "Valid" + i)) as TemplateField;
                    //if (column == null) return;
                    var isValid = col.ColumnName.IndexOf("Valid") >= 0;
                    if (isValid || col.ColumnName.IndexOf("TotalFlag") >= 0)
                    {
                        fields.Add(new Field
                        {
                            Name        = col.ColumnName,
                            DataType    = col.DataType,
                            ToolTip     = col.Caption,
                            Label       = col.Caption,
                            Visibility  = isValid ? Visibility.Visible : Visibility.Collapsed,
                            Width       = width,
                            Height      = height,
                            AllowFixing = AllowFieldFixing.No,
                            AllowResize = false,
                            Settings    =
                            {
                                SummaryUIType               = SummaryUIType.MultiSelect,
                                FilterOperandUIType         = FilterOperandUIType.Combo,
                                FilterOperatorDropDownItems = ComparisonOperatorFlags.None,
                                CellValuePresenterStyle     = fFlagStyle,
                                AllowEdit            = false,
                                AllowRecordFiltering = true,
                                //CellValuePresenterStyle = fFlagStyle,
                            },
                        });
                    }
                }
            }
            finally
            {
                fieldLayout.Fields.EndUpdate();
            }

            //XamDataGridHelper.ConfigureGrid(dataGrid, false, true, false, true, false);

            // раскрываем первую группу
            dataGrid.RecordsInViewChanged += ExpandFirstRecord;
        }