コード例 #1
0
        private void ResetValidation(SfTreeGrid grid, bool canResetRow)
        {
            var rowColumnIndex = grid.SelectionController.CurrentCellManager.CurrentRowColumnIndex;
            var dataRow        = grid.RowGenerator.Items.FirstOrDefault(item => item.RowIndex == rowColumnIndex.RowIndex);

            if (dataRow == null)
            {
                return;
            }
            var dataColumn = dataRow.VisibleColumns.FirstOrDefault(column => column.ColumnIndex == rowColumnIndex.ColumnIndex);

            if (dataColumn != null && dataColumn.ColumnElement != null)
            {
                SetCurrentCellValidated(true);
                if (!canResetRow)
                {
                    return;
                }
                SetCurrentRowValidated(true);
                dataRow.VisibleColumns.ForEach
                    (item =>
                {
                    if (!(item.ColumnElement is TreeGridCell))
                    {
                        return;
                    }
                    var gridcell = item.ColumnElement as TreeGridCell;
                    if (gridcell.eventErrorMessage != null)
                    {
                        gridcell.eventErrorMessage = string.Empty;
                    }
                    gridcell.ApplyValidationVisualState();
                });
            }
        }
コード例 #2
0
        /// <summary>
        /// Refreshes the column count, width in SfTreeGrid.
        /// </summary>
        /// <param name="treeGrid">
        /// The SfTreeGrid.
        /// </param>
        public static void RefreshColumns(this SfTreeGrid treeGrid)
        {
            if (treeGrid.TreeGridPanel == null)
            {
                return;
            }
            // Update column count
            treeGrid.UpdateColumnCount(false);

            // Update Indent column widths
            treeGrid.UpdateIndentColumnWidths();

            // Freeze columns updated when adding and removing columns
            treeGrid.UpdateFreezePaneColumns();
            // Update the scroll bars
            treeGrid.TreeGridPanel.UpdateScrollBars();
            treeGrid.TreeGridPanel.NeedToRefreshColumn = true;
            treeGrid.TreeGridPanel.InvalidateMeasure();

            if (treeGrid.TreeGridPanel.ColumnCount > 0)
            {
                // Refresh Column sizer
                treeGrid.TreeGridColumnSizer.Refresh();
            }
        }
コード例 #3
0
        public static int ResolveToGridVisibleColumnIndex(this SfTreeGrid treeGrid, int columnIndex)
        {
            var indentColumnCount  = treeGrid.showRowHeader ? 1 : 0;
            var visibleColumnIndex = columnIndex - indentColumnCount;

            return(visibleColumnIndex);
        }
コード例 #4
0
        internal static bool CanAllowNull(this SfTreeGrid treeGrid, PropertyInfo propertyinfo)
#endif
        {
            var nullablememberType = NullableHelperInternal.GetNullableType(propertyinfo.PropertyType);

            return(propertyinfo.PropertyType.IsAssignableFrom(nullablememberType));
        }
コード例 #5
0
 /// <summary>
 /// Disposes all the resources used by the <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeGridExpander"/> class.
 /// </summary>
 /// <param name="isDisposing">Indicates whether the call is from Dispose method or from a finalizer.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.treeGrid = null;
     }
 }
コード例 #6
0
        public TreeGridPropertiesProvider(SfTreeGrid treeGrid, TreeGridView view)
        {
            this.View     = view;
            this.TreeGrid = treeGrid;
            var itemproperties = view.GetItemProperties();

            if (itemproperties == null)
            {
                return;
            }
            foreach (var item in itemproperties)
            {
#if WPF
                var name         = (item as PropertyDescriptor).DisplayName;
                var propertyinfo = (item as PropertyDescriptor).ComponentType.GetProperty(name);
#else
                var name         = item.Key;
                var propertyinfo = item.Value;
#endif
                if (propertyinfo != null)
                {
                    PropertyAccessor accessor = new PropertyAccessor(propertyinfo);
                    itemaccessor.Add(name, accessor);
                }
            }
        }
コード例 #7
0
 public static int ResolveToNodeIndex(this SfTreeGrid treeGrid, int rowindex)
 {
     if (rowindex != -1)
     {
         return(rowindex - treeGrid.HeaderLineCount);
     }
     return(-1);
 }
コード例 #8
0
 public static int ResolveToRowIndex(this SfTreeGrid treeGrid, int nodeIndex)
 {
     if (nodeIndex <= -1)
     {
         return(-1);
     }
     return(nodeIndex + treeGrid.HeaderLineCount);  // header index is added
 }
コード例 #9
0
 /// <summary>
 /// Disposes all the resources used by the <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeGridModel"/> class.
 /// </summary>
 /// <param name="isDisposing">Indicates whether the call is from Dispose method or from a finalizer.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         UnwireEvents();
         this.treeGrid = null;
     }
 }
コード例 #10
0
        /// <summary>
        /// Gets the index of the row positioned at the start of the previous page that is not currently in view of SfTreeGrid.
        /// </summary>
        /// <returns>
        /// The start index of previous page.
        /// </returns>
        public static int GetPreviousPageIndex(this SfTreeGrid treeGrid)
        {
            int previousPageIndex = treeGrid.TreeGridPanel.ScrollRows.GetPreviousPage(treeGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex);
            var firstRowIndex     = treeGrid.GetFirstDataRowIndex();

            previousPageIndex = previousPageIndex < firstRowIndex ? firstRowIndex : previousPageIndex;
            return(previousPageIndex);
        }
コード例 #11
0
 public override void AttachTreeView(object treeGrid)
 {
     if (!(treeGrid is SfTreeGrid))
     {
         throw new InvalidOperationException("Attached view is not type of SfTreeGrid");
     }
     this.TreeGrid = treeGrid as SfTreeGrid;
 }
コード例 #12
0
        /// <summary>
        /// Hides the row focus border for the specified row index.
        /// </summary>
        /// <param name="treeGrid">
        /// The corresponding treeGrid to hide the row focus border.
        /// </param>
        /// <param name="rowIndex">
        /// The corresponding row index to hide row focus border.
        /// </param>
        internal static void HideRowFocusBorder(this SfTreeGrid treeGrid)
        {
            TreeDataRowBase row = treeGrid.RowGenerator.Items.FirstOrDefault(item => item.IsFocusedRow);

            if (row != null)
            {
                row.IsFocusedRow = false;
            }
        }
コード例 #13
0
        public void Drop(IDropInfo dropInfo)
        {
            // Source: Works, but...
            SfTreeGrid sourceControl = (SfTreeGrid)dropInfo.DragInfo.VisualSource;
            object     selectedItem  = sourceControl.SelectedItem; // If not selected before its NULL :(

            // Target: Don't know how to get it
            SfTreeGrid targetControl = (SfTreeGrid)dropInfo.VisualTarget;
            var        target        = dropInfo.TargetItem; // Not working :(
        }
コード例 #14
0
        public static TreeNode GetNodeAtRowIndex(this SfTreeGrid treeGrid, int rowIndex)
        {
            int nodeindex = treeGrid.ResolveToNodeIndex(rowIndex);

            if (nodeindex > -1 && treeGrid.View.Nodes.Count > nodeindex)
            {
                return(treeGrid.View.Nodes[nodeindex]);
            }
            return(null);
        }
コード例 #15
0
        /// <summary>
        /// Resolves the start column index of the SfTreeGrid.
        /// </summary>
        /// <param name="treeGrid">
        /// The SfTreeGrid.
        /// </param>
        /// <returns>
        /// Returns the start column index of the SfTreeGrid.
        /// </returns>
        public static int ResolveToStartColumnIndex(this SfTreeGrid treeGrid)
        {
            int startIndex = 0;

            if (treeGrid.showRowHeader)
            {
                startIndex += 1;
            }
            return(startIndex);
        }
コード例 #16
0
 /// <summary>
 /// Releases the unmanaged resources used by the Component and optionally releases the managed resources.
 /// </summary>
 /// <param name="disposing"><see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param>
 /// <remarks>See the documentation for the <see cref="System.ComponentModel.Component"/> class and its Dispose member.</remarks>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         Clear();
         this.content  = null;
         this.treeGrid = null;
     }
     base.Dispose(disposing);
 }
コード例 #17
0
        /// <summary>
        /// Replaces the node at specified index with the data in child nodes of the particular tree node.
        /// </summary>
        /// <param name="treeGrid">treeGrid.</param>
        /// <param name="node">The parent node. this is null if root node needs to be replaced.</param>
        /// <param name="data">the data.</param>
        /// <param name="index">the index.</param>
        /// <remarks>
        /// This is applicable only when you use the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.RequestTreeItems"/> event to populate the treegrid.
        /// </remarks>
        public static void ReplaceNode(this SfTreeGrid treeGrid, TreeNode node, object data, int index)
        {
            var view = treeGrid.View as TreeGridUnboundView;

            if (view == null)
            {
                throw new InvalidOperationException("ReplaceNode method is not applicable if RequestTreeItems is not used");
            }
            view.ReplaceNode(node, data, index);
        }
コード例 #18
0
        /// <summary>
        /// Determines whether the corresponding cell in a column is focusable or not.
        /// </summary>
        /// <param name="treeGrid">
        /// The SfTreeGrid.
        /// </param>
        /// <param name="rowColumnIndex">
        /// The corresponding rowcolumnindex to check whether the cells in a column is focusable or not.
        /// </param>
        /// <returns>
        /// Returns <b>true</b> if the cells in a column is focusable; otherwise, <b>false</b>.
        /// </returns>
        public static bool AllowFocus(this SfTreeGrid treeGrid, RowColumnIndex rowColumnIndex)
        {
            var gridColumn = treeGrid.GetTreeGridColumn(rowColumnIndex.ColumnIndex);

            if (gridColumn != null)
            {
                return(gridColumn.ActualWidth != 0d && !double.IsNaN(gridColumn.ActualWidth) && gridColumn.AllowFocus);
            }
            return(false);
        }
コード例 #19
0
        /// <summary>
        /// Clear child nodes of the particular node.
        /// </summary>
        /// <param name="node">The parent node. this is null if root nodes need to be cleared.</param>
        /// <remarks>
        /// This is applicable only when you use the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.RequestTreeItems"/> event to populate the treegrid.
        /// </remarks>
        public static void ResetNodes(this SfTreeGrid treeGrid, TreeNode node)
        {
            var view = treeGrid.View as TreeGridUnboundView;

            if (view == null)
            {
                throw new InvalidOperationException("ResetNodes method is not applicable if RequestTreeItems is not used");
            }
            view.ResetNodes(node);
        }
コード例 #20
0
        /// <summary>
        /// Moves the child node from an index to the another index in child nodes of particular tree node.
        /// </summary>
        /// <param name="treeGrid">treeGrid.</param>
        /// <param name="node">The parent node. this is null if root node needs to be moved.</param>
        /// <param name="oldIndex">the oldIndex.</param>
        /// <param name="newIndex">the newIndex.</param>
        /// <remarks>
        /// This is applicable only when you use the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.RequestTreeItems"/> event to populate the treegrid.
        /// </remarks>
        public static void MoveNode(this SfTreeGrid treeGrid, TreeNode node, int oldIndex, int newIndex)
        {
            var view = treeGrid.View as TreeGridUnboundView;

            if (view == null)
            {
                throw new InvalidOperationException("MoveNode method is not applicable if RequestTreeItems is not used");
            }

            view.MoveNode(node, oldIndex, newIndex);
        }
コード例 #21
0
 /// <summary>
 /// Disposes all the resources used by the <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeGridPropertiesProvider"/> class.
 /// </summary>
 /// <param name="isDisposing">Indicates whether the call is from Dispose method or from a finalizer.</param>
 protected virtual void Dispose(bool isDisposing)
 {
     this.cachedcolumn = null;
     if (this.itemaccessor != null)
     {
         this.itemaccessor.Clear();
     }
     this.itemaccessor = null;
     this.TreeGrid     = null;
     this.View         = null;
 }
コード例 #22
0
 /// <summary>
 /// Disposes all the resources used by the <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeGridCutCopyPaste"/> class.
 /// </summary>
 /// <param name="disposing"><see langword="true" /> to release all the resources. </param>
 protected virtual void Dispose(bool isDisposing)
 {
     if (isdisposed)
     {
         return;
     }
     if (isDisposing)
     {
         this.TreeGrid = null;
     }
     isdisposed = true;
 }
コード例 #23
0
        /// <summary>
        /// Raises the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.CurrentCellValidated"/> event.
        /// </summary>
        /// <param name="treeGrid">
        /// Specifies the corresponding grid .
        /// </param>
        /// <param name="column">
        /// The corresponding column that was in edit mode.
        /// </param>
        /// <param name="oldValue">
        /// The cell value before edited.
        /// </param>
        /// <param name="newValue">
        /// The cell value after editing completed.
        /// </param>
        protected void RaiseCurrentCellValidatedEvent(SfTreeGrid treeGrid, TreeGridColumn column, object oldValue, object newValue, object record, TreeNode treeNode)
        {
            var e = new TreeGridCurrentCellValidatedEventArgs(treeGrid)
            {
                OldValue = oldValue,
                NewValue = newValue,
                Column   = column,
                RowData  = record,
                Node     = treeNode
            };

            TreeGrid.RaiseCurrentCellValidatedEvent(e);
        }
コード例 #24
0
        /// <summary>
        /// Shows the row focus border for the specified row index.
        /// </summary>
        /// <param name="treeGrid">
        /// The corresponding treeGrid to enable the row focus border.
        /// </param>
        /// <param name="rowIndex">
        /// The corresponding row index to enable row focus border.
        /// </param>
        internal static void ShowRowFocusBorder(this SfTreeGrid treeGrid, int rowIndex)
        {
            if (treeGrid.NavigationMode != NavigationMode.Row)
            {
                return;
            }
            TreeDataRowBase row = treeGrid.RowGenerator.Items.FirstOrDefault(item => item.RowIndex == rowIndex);

            if (row != null && !row.IsSelectedRow)
            {
                row.IsFocusedRow = true;
            }
        }
コード例 #25
0
        public static int ResolveToRowIndex(this SfTreeGrid treeGrid, TreeNode node)
        {
            int nodeIndex = treeGrid.View.Nodes.IndexOf(node);

            if (nodeIndex != -1)
            {
                return(nodeIndex + treeGrid.HeaderLineCount);  // header index is added
            }
            else
            {
                return(-1);
            }
        }
コード例 #26
0
        public static int ResolveToRowIndex(this SfTreeGrid treeGrid, object data)
        {
            int nodeIndex = treeGrid.View.Nodes.GetIndexFromData(data);

            if (nodeIndex != -1)
            {
                return(nodeIndex + treeGrid.HeaderLineCount);  // header index is added
            }
            else
            {
                return(-1);
            }
        }
コード例 #27
0
 /// <summary>
 /// Export to PDF by excluding the non expanded nodes
 /// </summary>
 /// <param name="treeGrid"></param>
 /// <param name="exportingOptions"></param>
 /// <param name="excludeNonExpandedNodes"></param>
 /// <returns></returns>
 public static PdfDocument ExportToPdf(this SfTreeGrid treeGrid, TreeGridPdfExportingOptions exportingOptions, bool excludeNonExpandedNodes)
 {
     if (excludeNonExpandedNodes)
     {
         TreeGridCustomPdfConverter converter = new TreeGridCustomPdfConverter(excludeNonExpandedNodes);
         var pdfDocument = converter.ExportToPdf(treeGrid, exportingOptions);
         converter = null;
         return(pdfDocument);
     }
     else
     {
         return(treeGrid.ExportToPdf(exportingOptions));
     }
 }
コード例 #28
0
        /// <summary>
        /// Raises the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.CurrentCellValueChanged"/> event.
        /// </summary>
        /// <param name="treeGrid">
        /// The corresponding grid that contains the cell value changes .
        /// </param>
        /// <param name="dataColumn">
        /// The data column Which holds TreeGridColumn, RowColumnIndex and TreeGridCell.
        /// </param>
        public void RaiseCurrentCellValueChangedEvent(SfTreeGrid treeGrid, TreeDataColumnBase dataColumn)
        {
            var e = new TreeGridCurrentCellValueChangedEventArgs(treeGrid)
            {
                RowColumnIndex = new RowColumnIndex()
                {
                    RowIndex = dataColumn.RowIndex, ColumnIndex = dataColumn.ColumnIndex
                },
                Record = currentCellRendererElement.DataContext,
                Column = dataColumn.TreeGridColumn
            };

            TreeGrid.RaiseCurrentCellValueChangedEvent(e);
        }
コード例 #29
0
        /// <summary>
        /// Gets the index of the row positioned at the end of next page that is not currently in view of SfTreeGrid.
        /// </summary>
        /// <returns>
        /// Returns the end row index of next page.
        /// </returns>
        public static int GetNextPageIndex(this SfTreeGrid treeGrid)
        {
            var rowIndex = treeGrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex;

            if (rowIndex < treeGrid.GetFirstDataRowIndex())
            {
                rowIndex = 0;
            }
            var nextPageIndex = treeGrid.TreeGridPanel.ScrollRows.GetNextPage(rowIndex);
            var lastRowIndex  = treeGrid.GetLastDataRowIndex();

            nextPageIndex = nextPageIndex <= lastRowIndex ? nextPageIndex : lastRowIndex;
            return(nextPageIndex);
        }
コード例 #30
0
        /// <summary>
        /// Raises the <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.CurrentCellValidating"/> event.
        /// </summary>
        /// <param name="treeGrid">
        /// Specifies the corresponding grid .
        /// </param>
        /// <param name="column">
        /// The corresponding column that was in edit mode.
        /// </param>
        /// <param name="oldValue">
        /// The cell value before edited.
        /// </param>
        /// <param name="newValue">
        /// The value of the current cell is being edited.
        /// </param>
        /// <param name="changedNewValue">
        /// The cell value after editing completed.
        /// </param>
        /// <returns>
        /// <b>true</b> if <see cref="Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.CurrentCellValidating"/> event is raised; otherwise, <b>false</b>.
        /// </returns>
        protected bool RaiseCurrentCellValidatingEvent(SfTreeGrid treeGrid, TreeGridColumn column, object oldValue, object newValue, out object changedNewValue, object record, TreeNode treeNode)
        {
            var e = new TreeGridCurrentCellValidatingEventArgs(treeGrid)
            {
                OldValue = oldValue,
                NewValue = newValue,
                Column   = column,
                RowData  = record,
                Node     = treeNode
            };
            bool isSuspendValidating = TreeGrid.RaiseCurrentCellValidatingEvent(e);

            changedNewValue = e.NewValue;
            return(isSuspendValidating);
        }