/// <summary> /// Method which initialize the element with respect corresponding UnBound value /// </summary> /// <param name="dataColumn">DataColumn which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="dataContext">DataContext of the row</param> /// <remarks></remarks> public override void OnInitializeEditElement(DataColumnBase dataColumn, ContentControl uiElement, object dataContext) { var column = dataColumn.GridColumn as GridUnBoundColumn; object contentValue = null; if (dataContext != null) { contentValue = DataGrid.GetUnBoundCellValue(column, dataContext); } if (column.hasEditTemplate) { uiElement.ContentTemplate = column.EditTemplate; } if (column.hasEditTemplateSelector) { uiElement.ContentTemplateSelector = column.EditTemplateSelector; } var dataContextHelper = new DataContextHelper { Record = dataContext, Value = contentValue }; uiElement.Content = dataContextHelper; CanFocus = true; }
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); } }
/// <summary> /// Updates the content for the GridUnBoundRowCell. /// </summary> /// <param name="dataColumn"></param> /// <param name="uiElement"></param> /// <param name="dataContext"></param> public override void OnUpdateTemplateBinding(DataColumnBase dataColumn, ContentControl uiElement, object dataContext) { var contentValue = (dataColumn.GridUnBoundRowEventsArgs != null && dataColumn.GridUnBoundRowEventsArgs.Value != null) ? dataColumn.GridUnBoundRowEventsArgs.Value : string.Empty; uiElement.Content = contentValue; }
public override void OnInitializeEditElement(DataColumnBase dataColumn, TextBox uiElement, object dataContext) { var column = dataColumn.GridColumn; object contentValue = null; if (dataContext != null) { contentValue = DataGrid.GetUnBoundCellValue(column, dataContext); } uiElement.Text = contentValue == null ? null : contentValue.ToString(); var textPadding = new Binding { Path = new PropertyPath("Padding"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.PaddingProperty, textPadding); var textAlignBind = new Binding { Path = new PropertyPath("TextAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextAlignmentProperty, textAlignBind); var textWrappingBinding = new Binding { Path = new PropertyPath("TextWrapping"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextWrappingProperty, textWrappingBinding); uiElement.VerticalAlignment = VerticalAlignment.Stretch; var verticalContentAlignment = new Binding { Path = new PropertyPath("VerticalAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.VerticalContentAlignmentProperty, verticalContentAlignment); }
/// <summary> /// The method which updates the binding while reuse the UnBoundRow Cell's UIElement. /// </summary> /// <param name="dataColumn">DataColumn Which holds GridColumn, RowColumnIndex and GridCell</param> /// <param name="record">DataContext of the Row</param> /// <param name="isInEdit"></param> protected internal override void OnUpdateBindingInfo(DataColumnBase dataColumn, object record, bool isInEdit) { RowColumnIndex cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); FrameworkElement uiElement = dataColumn.ColumnElement; GridColumn column = dataColumn.GridColumn; FrameworkElement rendererElement = null; if (UseOnlyRendererElement) { rendererElement = uiElement as FrameworkElement; } else if (uiElement is GridCell) { rendererElement = (uiElement as GridCell).Content is FrameworkElement ? (uiElement as GridCell).Content as FrameworkElement : uiElement; } if (this.SupportsRenderOptimization && !isInEdit) { if ((dataColumn.GridUnBoundRowEventsArgs != null && !dataColumn.GridUnBoundRowEventsArgs.hasCellTemplate)) { OnUpdateDisplayBinding(dataColumn, (D)rendererElement, record); } else { OnUpdateTemplateBinding(dataColumn, (ContentControl)rendererElement, record); } } else { OnUpdateEditBinding(dataColumn, (E)rendererElement, record); } }
/// <summary> /// Initialize the binding for editor control of corresponding column. /// </summary> /// <param name="dataColumn">Specifies the dataColumn which contain GridColumn, RowColumnIndex</param> /// <param name="uiElement">Specifies the data context of the particular row</param> /// <param name="dataContext">Specifies the data context of the particular row</param> public override void OnInitializeEditElement(DataColumnBase dataColumn, E uiElement, object dataContext) { GridColumn column = dataColumn.GridColumn; #if WPF if (DataGrid.useDrawing) { uiElement.SetValue(Control.BorderThicknessProperty, new Thickness(0)); } #endif var textPadding = new Binding { Path = new PropertyPath("Padding"), Mode = BindingMode.OneWay, Source = column }; uiElement.SetBinding(Control.PaddingProperty, textPadding); var textAlignBind = new Binding { Path = new PropertyPath("TextAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextAlignmentProperty, textAlignBind); var textWrappingBinding = new Binding { Path = new PropertyPath("TextWrapping"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextWrappingProperty, textWrappingBinding); var verticalContentAlignment = new Binding { Path = new PropertyPath("VerticalAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.VerticalContentAlignmentProperty, verticalContentAlignment); #if WPF var textDecorations = new Binding { Path = new PropertyPath("TextDecorations"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(TextBox.TextDecorationsProperty, textDecorations); #endif uiElement.VerticalAlignment = VerticalAlignment.Stretch; }
public override void OnInitializeDisplayView(DataColumnBase dataColumn, UILabel view) { base.OnInitializeDisplayView(dataColumn, view); var gridcell = dataColumn.GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("Element")).GetValue(dataColumn); (gridcell as UIView).BackgroundColor = UIColor.White; }
/// <summary> /// Called when [initialize display element]. /// </summary> /// <param name="dataColumn">DataColumn which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeDisplayElement(DataColumnBase dataColumn, TextBlock uiElement, object dataContext) { GridColumn column = dataColumn.GridColumn; var cellvalue = DataGrid.GetUnBoundCellValue(column, dataContext); if (cellvalue == null) { uiElement.Text = string.Empty; } else { var type = cellvalue.GetType(); var unboundColumn = column as GridUnBoundColumn; //If both format, expression used in unbound column, then only format should be applied. if (!string.IsNullOrEmpty(unboundColumn.Format) && !string.IsNullOrEmpty(unboundColumn.Expression)) { uiElement.Text = String.Format((column as GridUnBoundColumn).Format, cellvalue); } else { uiElement.Text = cellvalue.ToString(); } } uiElement.VerticalAlignment = column.verticalAlignment; uiElement.Padding = dataColumn.GridColumn.padding; uiElement.SetValue(TextBlock.TextAlignmentProperty, column.textAlignment); uiElement.SetValue(TextBlock.TextTrimmingProperty, column.textTrimming); uiElement.SetValue(TextBlock.TextWrappingProperty, column.textWrapping); #if WPF uiElement.SetValue(TextBlock.TextDecorationsProperty, column.textDecoration); #endif }
protected override bool SearchCell(DataColumnBase column, object record, bool applySearchHighlightBrush) { if (column == null) { return(true); } if (column.GridColumn == null || DataGrid.View == null) { return(false); } var gridTemplateColumn = column.GridColumn as GridTemplateColumn; if (column.GridColumn.CellTemplate == null) { return(base.SearchCell(column, record, applySearchHighlightBrush)); } if (Provider == null) { Provider = DataGrid.View.GetPropertyAccessProvider(); } object data = Provider.GetFormattedValue(record, column.GridColumn.MappingName); if (MatchSearchText(column.GridColumn, record)) { return(ApplyInline(column, data, applySearchHighlightBrush)); } ClearSearchCell(column, record); return(false); }
/// <summary> /// Called when the UnBoundRow cell gets end edited. /// </summary> /// <param name="dc">DataColumnBase Which holds GridColumn, RowColumnIndex and GridCell</param> /// <param name="record">DataContext of the row</param> /// <param name="canResetBinding">Reset Binding the CurrentCell</param> /// <returns></returns> public override bool EndEdit(DataColumnBase dc, object record, bool canResetBinding = false) { var cellRowColumnIndex = new RowColumnIndex(dc.RowIndex, dc.ColumnIndex); var cellElement = dc.ColumnElement; var column = dc.GridColumn; if (!this.HasCurrentCellState) { return(false); } if (!this.IsInEditing) { return(false); } if (this.SupportsRenderOptimization) { #if WPF E uiElement = null; if (!UseOnlyRendererElement && cellElement is GridCell) { uiElement = (E)((cellElement as GridCell).Content is FrameworkElement ? (cellElement as GridCell).Content as FrameworkElement : cellElement); } else { uiElement = cellElement as E; } uiElement.PreviewLostKeyboardFocus -= OnLostKeyboardFocus; #endif //this.IsFocused = false; this.SetFocus(false); GridUnBoundRowEventsArgs gridUnBoundRowEventsArgs = (cellElement as GridCell).ColumnBase.GridUnBoundRowEventsArgs; var dataColumn = (cellElement as GridCell).ColumnBase; OnEditingComplete(dataColumn, CurrentCellRendererElement); if (!UseOnlyRendererElement && cellElement == null) { throw new Exception("Cell Element will not be get null for any case"); } OnUnloadUIElements(dataColumn); OnPrepareUIElements(dataColumn, record, false); if (gridUnBoundRowEventsArgs != null && !gridUnBoundRowEventsArgs.hasCellTemplate) { UpdateCurrentCellState((cellElement as GridCell).Content as FrameworkElement, false); } else { UpdateCurrentCellState(cellElement as FrameworkElement, false); } } else { UpdateCurrentCellState(this.CurrentCellRendererElement, false); } return(!this.IsInEditing); }
public override void OnInitializeEditElement(DataColumnBase dataColumn, ComboBoxAdv uiElement, object dataContext) { //To sort the items while the DropDown for filter cell is initialized. base.OnInitializeEditElement(dataColumn, uiElement, dataContext); SortDescription sd = new SortDescription("DisplayText", ListSortDirection.Ascending); uiElement.Items.SortDescriptions.Add(sd); }
public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfLabel view) { base.OnInitializeDisplayView(dataColumn, view); if (dataColumn.GridColumn.MappingName == "Hours") { view.Text = "Total"; } }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">DataColumn which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="filterValue">The data context.</param> public override void OnInitializeEditElement(DataColumnBase dataColumn, TextBox uiElement, object dataContext) { var filterValue = dataColumn.GridColumn.FilteredFrom == FilteredFrom.FilterRow && dataColumn.GridColumn.FilterPredicates.Count > 0 ? dataColumn.GridColumn.FilterPredicates.FirstOrDefault().FilterValue : null; uiElement.Text = filterValue != null ? (string)filterValue : string.Empty; base.OnInitializeEditElement(dataColumn, uiElement, filterValue); }
/// <summary> /// When complete edit, we need to raise query again to provide entered value to customer. /// </summary> /// <param name="dataColumn">DataColumn which holds GridColumn, RowColumnIndex and GridCell </param> /// <param name="currentRendererElement">The UIElement that was loaded in edit mdoe</param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// GridColumn - Column which is providing the information for Binding protected override void OnEditingComplete(DataColumnBase dataColumn, FrameworkElement currentRendererElement) { base.OnEditingComplete(dataColumn, currentRendererElement); if (HasCurrentCellState && this.IsValueChanged && !this.FilterRowCell.DataColumn.GridColumn.ImmediateUpdateColumnFilter) { this.ProcessSingleFilter(GetControlValue()); } }
/// <summary> /// Called from <see> /// <cref>IGridCellRenderer.PrepareUIElments</cref> /// </see> /// to /// prepare the UnBoundRow cells UIElement children. /// VirtualizingCellRendererBase overrides this method and /// creates new UIElements and wires them with the parent cells control. /// </summary> /// <param name="dataColumn">DataColumn Which holds GridColumn, RowColumnIndex and GridCell </param> /// <param name="record">record of the row </param> /// <param name="isInEdit"></param> /// <returns></returns> protected internal override FrameworkElement OnPrepareUIElements(DataColumnBase dataColumn, object record, bool isInEdit) { RowColumnIndex cellRowColumnIndex = new RowColumnIndex(dataColumn.RowIndex, dataColumn.ColumnIndex); FrameworkElement cellContainer = dataColumn.ColumnElement; FrameworkElement cellcontent = null; GridUnBoundRowEventsArgs gridUnBoundRowEventsArgs = dataColumn.GridUnBoundRowEventsArgs; // Create GridCell only for editable columns // UseOnlyRendererElement for Non-Editable columns if (!UseOnlyRendererElement && cellContainer == null) { cellContainer = OnPrepareUIElements(); } if (this.SupportsRenderOptimization && !isInEdit) { if ((gridUnBoundRowEventsArgs != null && !gridUnBoundRowEventsArgs.hasCellTemplate)) { // Cell Content will be created for Non Template cells. cellcontent = CreateOrRecycleDisplayUIElement(); InitializeDisplayElement(dataColumn, (D)cellcontent, record); WireDisplayUIElement((D)cellcontent); } else { // We wont create Cell Content for Templated cells. // GridCell is used as RendererElement with template case. InitializeTemplateElement(dataColumn, (ContentControl)cellContainer, record); WireTemplateUIElement((ContentControl)cellContainer); } if (cellcontent != null) { (cellContainer as GridCell).Content = cellcontent; } } else { cellcontent = CreateOrEditRecycleUIElement(); if (dataColumn.GridColumn != null) { dataColumn.GridColumn.IsInSuspend = true; } InitializeEditElement(dataColumn, (E)cellcontent, record); if (dataColumn.GridColumn != null) { dataColumn.GridColumn.IsInSuspend = false; } WireEditUIElement((E)cellcontent); // GridImageColumn, GridHyperLinkColumn and GridCheckBoxColumn are Non-editable columns. //So content created and set to GridCell. if (cellcontent != null && cellContainer is GridCell) { (cellContainer as GridCell).Content = cellcontent; } } return(UseOnlyRendererElement ? cellcontent : cellContainer); }
public override void OnUpdateDisplayValue(DataColumnBase dataColumn, GridRowHeaderCell view) { UILabel rowHeader = (UILabel)view.Subviews[0]; // RowHeader's text is updated when the datagrid is scrolled rowHeader.Text = dataColumn.RowIndex.ToString(); base.OnUpdateDisplayValue(dataColumn, view); }
public override bool EndEdit(DataColumnBase dc, object record, bool canResetBinding = false) { if (canResetBinding) { var CurrentCellUIElement = (CurrencyTextBox)CurrentCellRendererElement; CurrentCellUIElement.ClearValue(CurrencyTextBox.ValueProperty); } return(base.EndEdit(dc, record, canResetBinding)); }
public override bool EndEdit(DataColumnBase dc, object record, bool canResetBinding = false) { if (canResetBinding) { var CurrentCellUIElement = (SfMultiColumnDropDownControl)CurrentCellRendererElement; CurrentCellUIElement.ClearValue(SfMultiColumnDropDownControl.SelectedValueProperty); } return(base.EndEdit(dc, record, canResetBinding)); }
public override void OnInitializeEditElement(DataColumnBase dataColumn, CurrencyTextBox uiElement, object dataContext) { base.OnInitializeEditElement(dataColumn, uiElement, dataContext); var binding = new Binding { Converter = new CurrencyConverter() }; uiElement.SetBinding(CurrencyTextBox.CurrencySymbolProperty, binding); }
public override void OnUpdateEditBinding(DataColumnBase dataColumn, GridStackedHeaderCellControl element, object dataContext) { element.ClearValue(GridStackedHeaderCellControl.ContentProperty); var bind = new Binding { Path = new PropertyPath("HeaderText"), Mode = BindingMode.TwoWay }; element.SetBinding(GridHeaderCellControl.ContentProperty, bind); }
public override void OnInitializeEditElement(DataColumnBase dataColumn, GridStackedHeaderCellControl uiElement, object dataContext) { var bind = new Binding { Path = new PropertyPath("HeaderText"), Mode = BindingMode.TwoWay }; uiElement.SetBinding(ContentControl.ContentProperty, bind); uiElement.DataContext = dataContext; }
protected override void OnKeyUp(DataColumnBase dataColumn, RowColumnIndex rowColumnIndex, KeyEventArgs e) { if (e.KeyData == Keys.Tab) { dataGrid.CurrentCell.BeginEdit(); //To open the dropdown SfCombo.ShowDropDown(); } }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">DataColumn Which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeEditElement(DataColumnBase dataColumn, DoubleTextBox uiElement, object dataContext) { base.OnInitializeEditElement(dataColumn, uiElement, dataContext); InitializeEditUIElement(uiElement, dataColumn.GridColumn); #if WinRT || UNIVERSAL uiElement.ValueChangedMode = ValueChange.OnKeyFocus; #else uiElement.TextSelectionOnFocus = false; #endif }
public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfLabel view) { base.OnInitializeDisplayView(dataColumn, view); base.OnInitializeDisplayView(dataColumn, view); view.HorizontalTextAlignment = TextAlignment.Center; view.BackgroundColor = Color.Gray; view.FontAttributes = FontAttributes.Italic; view.FontSize = 20; view.TextColor = Color.White; }
/// <summary> /// Called when [initialize display element]. /// </summary> /// <param name="dataColumn">DataColumn Which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="dataContext">The data context.</param> public override void OnInitializeDisplayElement(DataColumnBase dataColumn, D uiElement, object dataContext) { var column = dataColumn.GridColumn; var textBind = new Binding { Path = new PropertyPath("FilterRowText"), Mode = BindingMode.TwoWay, Source = column, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; uiElement.SetBinding(TextBlock.TextProperty, textBind); var verticalAlignment = new Binding { Path = new PropertyPath("VerticalAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.VerticalAlignmentProperty, verticalAlignment); uiElement.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Left); }
/// <summary> /// Called when [initialize edit element]. /// </summary> /// <param name="dataColumn">DataColumn which holds GridColumn, RowColumnIndex and GridCell </param> /// RowColumnIndex - RowColumnIndex for the Renderer Element /// <param name="uiElement">Corresponding Renderer Element</param> /// GridColumn - Column which is providing the information for Binding /// <param name="filterValue">The data context.</param> public override void OnInitializeEditElement(DataColumnBase dataColumn, E uiElement, object dataContext) { var column = dataColumn.GridColumn; var textPadding = new Binding { Path = new PropertyPath("Padding"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.PaddingProperty, textPadding); uiElement.SetValue(TextBox.TextAlignmentProperty, TextAlignment.Left); uiElement.VerticalAlignment = VerticalAlignment.Stretch; var verticalContentAlignment = new Binding { Path = new PropertyPath("VerticalAlignment"), Mode = BindingMode.TwoWay, Source = column }; uiElement.SetBinding(Control.VerticalContentAlignmentProperty, verticalContentAlignment); }
/// <summary> /// Override method to get a custom Display View as Label /// </summary> /// <param name="dataColumn">DataColumnBase type of dataColumn parameter</param> /// <param name="view">view is Label type parameter</param> public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfLabel view) { base.OnInitializeDisplayView(dataColumn, view); if (view != null) { view.FontFamily = dataColumn.GridColumn.RecordFont; view.FontAttributes = Xamarin.Forms.FontAttributes.Bold; view.FontSize = 16; } }
public override void OnUpdateTemplateBinding(DataColumnBase dataColumn, ContentControl uiElement, object dataContext) { uiElement.ClearValue(ContentControl.ContentProperty); var dataContextHelper = new DataContextHelper { Record = dataContext }; dataContextHelper.SetValueBinding(dataColumn.GridColumn.DisplayBinding, dataContext); uiElement.Content = dataContextHelper; }
/// <summary> /// Override method to get a custom Display View as Label /// </summary> /// <param name="dataColumn">DataColumnBase type of dataColumn parameter</param> /// <param name="view">view is Label type parameter</param> public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfLabel view) { base.OnInitializeDisplayView(dataColumn, view); if (view != null) { view.TextColor = Color.FromHex("#0079FF"); view.FontFamily = dataColumn.GridColumn.RecordFont; view.FontSize = 16; } }
protected override void OnEnteredEditMode(DataColumnBase dataColumn, FrameworkElement currentRendererElement) { #if WPF if ((currentRendererElement as ComboBox).StaysOpenOnEdit && (currentRendererElement as ComboBox).IsEditable) { (currentRendererElement as ComboBox).IsDropDownOpen = true; } #endif base.OnEnteredEditMode(dataColumn, currentRendererElement); }