Exemplo n.º 1
0
        protected override void OnViewChange()
        {
            base.OnViewChange();
            _inLabelEdit = false;
            availableFieldsTreeColumns.ViewEditor     = ViewEditor;
            availableFieldsTreeColumns.RootColumn     = ViewInfo.ParentColumn;
            availableFieldsTreeColumns.SublistId      = ViewInfo.SublistId;
            availableFieldsTreeColumns.CheckedColumns = ListColumnsInView();
            IList <DisplayColumn> gridColumns =
                ImmutableList.ValueOf(ViewEditor.ViewInfo.DisplayColumns.Where(col => !col.ColumnSpec.Hidden));

            if (gridColumns.Count != VisibleColumns.Count)
            {
                gridColumns = VisibleColumns;
            }
            ListViewHelper.ReplaceItems(listViewColumns,
                                        gridColumns.Select(MakeListViewColumnItem).ToArray());
            if (null != SelectedPaths)
            {
                var selectedIndexes = VisibleColumns
                                      .Select((col, index) => new KeyValuePair <DisplayColumn, int>(col, index))
                                      .Where(kvp => SelectedPaths.Contains(kvp.Key.PropertyPath))
                                      .Select(kvp => kvp.Value);
                ListViewHelper.SelectIndexes(listViewColumns, selectedIndexes);
            }
            UpdateButtons();
        }
Exemplo n.º 2
0
        internal void ApplyFixedRowVisualState(bool isfixed)
        {
            if (isfixed)
            {
                foreach (var cell in VisibleColumns.Select(column => column.ColumnElement as GridCell))
                {
                    if (cell.GridCellRegion != "LastColumnCell")
                    {
                        if (cell is GridIndentCell)
                        {
                            if ((cell as GridIndentCell).ColumnType == IndentColumnType.AfterExpander)
                            {
                                VisualStateManager.GoToState(cell, "Fixed_NormalCell", false);
                            }
                        }
                        else
                        {
#if WPF
                            if (DataGrid.useDrawing && cell is GridCaptionSummaryCell)
                            {
                                cell.GridCellRegion = "Fixed_NormalCell";
                            }
#endif
                            VisualStateManager.GoToState(cell, "Fixed_NormalCell", false);
                        }
                    }
                    else
                    {
#if WPF
                        if (DataGrid.useDrawing && cell is GridCaptionSummaryCell)
                        {
                            cell.GridCellRegion = "Fixed_LastCell";
                        }
#endif
                        VisualStateManager.GoToState(cell, "Fixed_LastCell", false);
                    }
                }
            }
            else
            {
                foreach (var cell in VisibleColumns.Select(column => column.ColumnElement as GridCell))
                {
                    if (cell is GridIndentCell)
                    {
                        var indentCell = cell as GridIndentCell;
                        indentCell.ApplyIndentVisualState(indentCell.ColumnType);
                    }
                    else
                    {
                        cell.ApplyGridCellVisualStates(cell.GridCellRegion);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public void AddColumn(PropertyPath propertyPath)
 {
     List<ColumnSpec> columnSpecs = new List<ColumnSpec>(VisibleColumns.Select(col=>col.ColumnSpec));
     var newColumn = new ColumnSpec(propertyPath);
     if (listViewColumns.SelectedIndices.Count == 0)
     {
         columnSpecs.Add(newColumn);
     }
     else
     {
         columnSpecs.Insert(listViewColumns.SelectedIndices.Cast<int>().Min(), newColumn);
     }
     ColumnSpecs = columnSpecs;
 }
Exemplo n.º 4
0
 protected override void OnViewChange()
 {
     base.OnViewChange();
     _inLabelEdit = false;
     availableFieldsTreeColumns.RootColumn = ViewInfo.ParentColumn;
     availableFieldsTreeColumns.ShowAdvancedFields = ViewEditor.ShowHiddenFields;
     availableFieldsTreeColumns.SublistId = ViewInfo.SublistId;
     availableFieldsTreeColumns.CheckedColumns = ListColumnsInView();
     ListViewHelper.ReplaceItems(listViewColumns,
         VisibleColumns.Select(MakeListViewColumnItem).ToArray());
     if (null != SelectedPaths)
     {
         var selectedIndexes = VisibleColumns
             .Select((col, index) => new KeyValuePair<DisplayColumn, int>(col, index))
             .Where(kvp => SelectedPaths.Contains(kvp.Key.PropertyPath))
             .Select(kvp => kvp.Value);
         ListViewHelper.SelectIndexes(listViewColumns, selectedIndexes);
     }
     UpdateButtons();
 }
Exemplo n.º 5
0
        public List <PropertyInfo> GetColumns()
        {
            if (_columns == null)
            {
                var allColumns = typeof(T).GetProperties()
                                 .Where(p => !ColumnsConfig.ColumnsToIgnore.Contains(p.Name)).ToList();

                if (VisibleColumns.Any())
                {
                    var invalidColumns = VisibleColumns.Where(v => !allColumns.Select(c => c.Name).Contains(v));
                    if (invalidColumns.Any())
                    {
                        throw new InvalidColumnNameException(invalidColumns.ToDelimitedString());
                    }
                }

                var orderedColumns = VisibleColumns.Select(visibleColumn => allColumns.FirstOrDefault(c => c.Name == visibleColumn)).ToList();
                orderedColumns.AddRange(allColumns.Where(c => !c.IsVirtual() && !orderedColumns.Contains(c)));

                _columns = new List <PropertyInfo>();
                _columns.AddRange(orderedColumns);
            }
            return(_columns);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Returns the set of columns that should be checked in the Available Fields Tree.
 /// </summary>
 private IEnumerable<PropertyPath> ListColumnsInView()
 {
     return VisibleColumns.Select(dc => dc.PropertyPath);
 }
Exemplo n.º 7
0
        public override void WriteInitializationScript(TextWriter writer)
        {
            var options = new Dictionary <string, object>(Events);

            var autoBind = DataSource.Type != DataSourceType.Server && AutoBind.GetValueOrDefault(true);

            var columns = VisibleColumns.Select(c => c.ToJson());

            var idPrefix = "#";

            if (IsInClientTemplate)
            {
                idPrefix = "\\" + idPrefix;
            }

            if (columns.Any())
            {
                options["columns"] = columns;
            }

            if (Grouping.Enabled)
            {
                options["groupable"] = Grouping.ToJson();
            }

            if (Pageable.Enabled)
            {
                Pageable.AutoBind = autoBind;

                options["pageable"] = Pageable.ToJson();
            }

            if (Sortable.Enabled)
            {
                var sorting = Sortable.ToJson();
                options["sortable"] = sorting.Any() ? (object)sorting : true;
            }

            if (Selectable.Enabled)
            {
                options["selectable"] = String.Format("{0}, {1}", Selectable.Mode, Selectable.Type);
            }

            if (Filterable.Enabled)
            {
                var filtering = Filterable.ToJson();
                options["filterable"] = filtering.Any() ? (object)filtering : true;
            }

            if (ColumnMenu.Enabled)
            {
                var menu = ColumnMenu.ToJson();
                options["columnMenu"] = menu.Any() ? (object)menu : true;
            }

            if (Resizable.Enabled)
            {
                options["resizable"] = true;
            }

            if (ColumnResizeHandleWidth != defaultColumnResizeHandleWidth)
            {
                options["columnResizeHandleWidth"] = ColumnResizeHandleWidth;
            }

            if (Reorderable.Enabled)
            {
                options["reorderable"] = true;
            }

            if (!Scrollable.Enabled)
            {
                options["scrollable"] = false;
            }
            else
            {
                var scrolling = Scrollable.ToJson();
                if (scrolling.Any())
                {
                    options["scrollable"] = scrolling;
                }
            }

            if (Editable.Enabled)
            {
                options["editable"] = Editable.ToJson();
            }

            if (ToolBar.Enabled)
            {
                options["toolbar"] = ToolBar.ToJson();
            }

            if (autoBind == false)
            {
                options["autoBind"] = autoBind;
            }

            options["dataSource"] = DataSource.ToJson();

            if (!String.IsNullOrEmpty(ClientDetailTemplateId))
            {
                options["detailTemplate"] = new ClientHandlerDescriptor {
                    HandlerName = String.Format("kendo.template($('{0}{1}').html())", idPrefix, ClientDetailTemplateId)
                };
            }

            if (!String.IsNullOrEmpty(ClientRowTemplate))
            {
                options["rowTemplate"] = ClientRowTemplate;
            }

            if (!String.IsNullOrEmpty(ClientAltRowTemplate))
            {
                options["altRowTemplate"] = ClientAltRowTemplate;
            }

            if (Navigatable.Enabled)
            {
                options["navigatable"] = true;
            }

            if (Mobile != MobileMode.Disabled)
            {
                if (Mobile == MobileMode.Auto)
                {
                    options["mobile"] = true;
                }
                else
                {
                    options["mobile"] = Mobile.ToString().ToLowerInvariant();
                }
            }

            writer.Write(Initializer.Initialize(Selector, "Grid", options));

            base.WriteInitializationScript(writer);
        }