protected override void ReadElementInObject( XmlReader reader, PropertyDescriptor property, object toRead) { base.ReadElementInObject(reader, property, toRead); GridViewTemplate template = toRead as GridViewTemplate; if (template == null || !(property.Name == "FilterDescriptors")) { return; } this.ProcessFilterDescriptors(template, template.FilterDescriptors); }
public void BeginEdit() { GridViewTemplate viewTemplate = this.row.ViewTemplate; if (!this.row.IsCurrent || !this.column.IsCurrent) { GridViewSynchronizationService.RaiseCurrentChanged(viewTemplate, this.row, this.column, true); } viewTemplate.OnViewChanged((object)viewTemplate, new DataViewChangedEventArgs(ViewChangedAction.BeginEdit, (IList) new object[2] { (object)this.row, (object)this.column })); }
public void EndEdit() { GridViewTemplate viewTemplate = this.row.ViewTemplate; if (!this.row.IsCurrent || !this.column.IsCurrent) { return; } viewTemplate.OnViewChanged((object)viewTemplate, new DataViewChangedEventArgs(ViewChangedAction.EndEdit, (IList) new object[2] { (object)this.row, (object)this.column })); }
public static bool IsEventSuspended(GridViewTemplate template, KnownEvents eventId) { if (template == null) { throw new ArgumentNullException("Template"); } MasterGridViewTemplate masterTemplate = template.MasterTemplate; if (masterTemplate != null) { return(masterTemplate.SynchronizationService.IsEventSuspended(eventId)); } return(false); }
private void RebuildViews() { if (this.ViewTemplate == null) { return; } int index1 = 0; while (index1 < this.views.Count) { GridViewTemplate viewTemplate = this.views[index1].ViewTemplate; if (viewTemplate == null || !this.ViewTemplate.Templates.Contains(viewTemplate)) { if (viewTemplate == this.ViewTemplate && this.ViewTemplate.IsSelfReference) { ++index1; } else { this.views.RemoveAt(index1); } } else { ++index1; } } int count = this.ViewTemplate.Templates.Count; if (this.ViewTemplate.IsSelfReference) { ++count; } if (this.views.Count != count) { GridViewInfo[] gridViewInfoArray = new GridViewInfo[this.views.Count]; this.views.CopyTo(gridViewInfoArray, 0); this.views.Clear(); for (int index2 = 0; index2 < this.ViewTemplate.Templates.Count; ++index2) { this.views.Add(this.Find(gridViewInfoArray, this.ViewTemplate.Templates[index2]) ?? new GridViewInfo(this.ViewTemplate.Templates[index2], this)); } } if (!this.ViewTemplate.IsSelfReference || this.views.Contains(this.ViewTemplate.MasterViewInfo)) { return; } this.views.Insert(0, this.ViewTemplate.MasterViewInfo); }
private void Form1_Load(object sender, EventArgs e) { FillPeople(); FillAddresses(); radGridView1.DataSource = people; GridViewTemplate template = new GridViewTemplate(); template.DataSource = addresses; radGridView1.MasterTemplate.Templates.Add(template); GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = template; relation.RelationName = "PersonAddress"; relation.ParentColumnNames.Add("Id"); relation.ChildColumnNames.Add("PersonId"); radGridView1.Relations.Add(relation); }
/// <summary> /// /// </summary> /// <param name="grid"></param> /// <param name="multiselect"></param> /// <param name="allowDelete"></param> /// <param name="removeBorder"></param> public static void SetPropertiesToList(this GridViewTemplate grid, bool multiselect, bool allowDelete, bool removeBorder = true) { grid.AllowAddNewRow = false; grid.AllowColumnChooser = false; grid.AllowDeleteRow = allowDelete; grid.AllowEditRow = false; grid.AllowRowReorder = false; grid.AllowRowResize = false; grid.AutoGenerateColumns = true; grid.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill; grid.ReadOnly = true; grid.ShowColumnHeaders = false; grid.ShowFilteringRow = false; grid.ShowRowHeaderColumn = false; }
private void AddColumnMenuItems( RadMenuItem parentItem, GridViewTemplate template, string headerItemName) { List <RadMenuItemBase> radMenuItemBaseList = new List <RadMenuItemBase>(); radMenuItemBaseList.Add((RadMenuItemBase) new RadMenuHeaderItem(headerItemName)); RadMenuItem radMenuItem1 = new RadMenuItem(LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("SearchRowMenuItemAllColumns"), (object)template); radMenuItem1.Click += new EventHandler(this.ColumnItem_Click); radMenuItem1.IsChecked = true; radMenuItemBaseList.Add((RadMenuItemBase)radMenuItem1); radMenuItemBaseList.Add((RadMenuItemBase) new RadMenuSeparatorItem()); foreach (GridViewDataColumn column in (Collection <GridViewDataColumn>)template.Columns) { if (column.IsVisible) { RadMenuItem radMenuItem2 = new RadMenuItem(column.HeaderText, (object)column); radMenuItem2.Click += new EventHandler(this.ColumnItem_Click); radMenuItem2.IsChecked = column.AllowSearching; radMenuItemBaseList.Add((RadMenuItemBase)radMenuItem2); if (!radMenuItem2.IsChecked) { radMenuItem1.IsChecked = false; } } } if (template.Templates.Count > 0) { RadMenuHeaderItem radMenuHeaderItem = new RadMenuHeaderItem(LocalizationProvider <RadGridLocalizationProvider> .CurrentProvider.GetLocalizedString("SearchRowMenuItemChildTemplates")); radMenuHeaderItem.Margin = new Padding(0, 5, 0, 0); radMenuItemBaseList.Add((RadMenuItemBase)radMenuHeaderItem); foreach (GridViewTemplate template1 in (Collection <GridViewTemplate>)template.Templates) { string text = template1.Caption; if (string.IsNullOrEmpty(text)) { text = "Child Template " + (object)(template.Templates.IndexOf(template1) + 1); } RadMenuItem parentItem1 = new RadMenuItem(text); parentItem1.DropDownClosing += new RadPopupClosingEventHandler(this.ChooseColumnsMenuItem_DropDownClosing); this.AddColumnMenuItems(parentItem1, template1, template1.Caption); radMenuItemBaseList.Add((RadMenuItemBase)parentItem1); } } parentItem.Items.AddRange((RadItem[])radMenuItemBaseList.ToArray()); }
public void AddSelfReference( GridViewTemplate template, string[] parentColumnNames, string[] childColumnNames) { if (this.Find(template, template) != null) { throw new InvalidOperationException("SelfReference relation for this GridViewTemplate already exsist"); } GridViewRelation gridViewRelation = new GridViewRelation(template); gridViewRelation.ChildTemplate = template; gridViewRelation.ParentColumnNames.AddRange(parentColumnNames); gridViewRelation.ChildColumnNames.AddRange(childColumnNames); this.Add(gridViewRelation); }
public GridViewCellInfo this[string name] { get { GridViewTemplate viewTemplate = this.rowInfo.ViewTemplate; if (viewTemplate != null) { GridViewDataColumn column = viewTemplate.Columns[name]; if (column != null) { return(this.GetCellInfo((GridViewColumn)column)); } } return((GridViewCellInfo)null); } }
private void CallViewChanged(string propertyName) { if (this.IsSuspended) { return; } GridViewTemplate template = this.FindTemplate(); if (template == null) { return; } PropertyChangedEventArgs changedEventArgs = new PropertyChangedEventArgs(propertyName); template.OnViewChanged((object)this, new DataViewChangedEventArgs(ViewChangedAction.ColumnGroupPropertyChanged, (object)changedEventArgs)); }
public GridViewCollectionChangedEventArgs( GridViewTemplate template, NotifyCollectionChangedAction action, IList newItems, IList oldItems, int newStartingIndex, int oldStartingIndex, string propertyName) : base(action) { this.Action = action; this.NewItems = newItems; this.OldItems = oldItems; this.NewStartingIndex = newStartingIndex; this.OldStartingIndex = oldStartingIndex; this.PropertyName = propertyName; this.gridViewTemplate = template; }
internal static void RaiseGroupByChanged( GridViewTemplate template, GroupDescriptor groupDescription, NotifyCollectionChangedAction action) { GridGroupByExpression fromDescriptor = GridGroupByExpression.CreateFromDescriptor(groupDescription); template.EventDispatcher.ResumeEvent(EventDispatcher.GroupByChanging); template.EventDispatcher.ResumeEvent(EventDispatcher.GroupByChanged); if (action != NotifyCollectionChangedAction.Add && action != NotifyCollectionChangedAction.ItemChanged && (action != NotifyCollectionChangedAction.Batch && action != NotifyCollectionChangedAction.Remove)) { throw new ArgumentException("Invalid action"); } template.MasterTemplate.SynchronizationService.EndDispatch(true); GridViewCollectionChangedEventArgs args = new GridViewCollectionChangedEventArgs(template, action, (object)fromDescriptor, (object)null, 0, string.Empty); template.EventDispatcher.RaiseEvent <GridViewCollectionChangedEventArgs>(EventDispatcher.GroupByChanged, (object)template, args); }
private void CreateUnboundHierarchy() { using (this.radGridView1.DeferRefresh()) { this.radGridView1.MasterTemplate.Reset(); SetupMasterForUnbound(); GridViewTemplate template = SetupChildForUnbound(); GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate, template); relation.RelationName = "EmployeesOrders"; relation.ParentColumnNames.Add("Name"); relation.ChildColumnNames.Add("Name"); radGridView1.Relations.Add(relation); } this.radGridView1.ChildRows[0].IsExpanded = true; }
private void UpdateChildRowViewInfo(GridViewRowInfo newRow) { GridViewTemplate parent = this.owner.Parent; if (parent == null) { return; } GridViewRelationDataProvider hierarchyDataProvider = this.owner.HierarchyDataProvider as GridViewRelationDataProvider; if (hierarchyDataProvider == null) { return; } hierarchyDataProvider.Refresh(); foreach (GridViewRowInfo childRow in parent.ChildRows) { bool flag = true; for (int index = 0; index < hierarchyDataProvider.Relation.ParentColumnNames.Count; ++index) { if (!object.Equals(childRow.Cells[hierarchyDataProvider.Relation.ParentColumnNames[index]].Value, newRow.Cells[hierarchyDataProvider.Relation.ChildColumnNames[index]].Value)) { flag = false; break; } } if (flag) { using (IEnumerator <GridViewInfo> enumerator = ((GridViewHierarchyRowInfo)childRow).Views.GetEnumerator()) { while (enumerator.MoveNext()) { GridViewInfo current = enumerator.Current; if (current.ViewTemplate == this.owner) { newRow.ViewInfo = current; break; } } break; } } } }
private void AppendTemplateCacheKey( StringBuilder sb, GridViewTemplate template, string templateName) { sb.Append(string.Format(";{0}", (object)templateName)); foreach (GridViewDataColumn column in (Collection <GridViewDataColumn>)template.Columns) { if (column.AllowSearching) { sb.Append(string.Format("{0},", (object)column.Index)); } } --sb.Length; foreach (GridViewTemplate template1 in (Collection <GridViewTemplate>)template.Templates) { this.AppendTemplateCacheKey(sb, template1, template1.Caption); } }
private void SetUpGrid() { ((IDbSet <OrderType>) this.data.OrderTypes.All()).Load(); this.radGridView1.DataSource = ((IDbSet <OrderType>) this.data.OrderTypes.All()).Local.ToBindingList(); this.radGridView1.Columns["Orders"].IsVisible = false; this.radGridView1.Columns["Shippers"].IsVisible = false; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTemplate ordersTemplate = new GridViewTemplate(); ordersTemplate.Caption = "Orders"; radGridView1.MasterTemplate.Templates.Add(ordersTemplate); ((IDbSet <Order>) this.data.Orders.All()).Load(); ordersTemplate.DataSource = ((IDbSet <Order>) this.data.Orders.All()).Local.ToBindingList(); ordersTemplate.Columns["OrderType"].IsVisible = false; ordersTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = ordersTemplate; relation.RelationName = "OrderTypesOrders"; relation.ParentColumnNames.Add("OrderTypeId"); relation.ChildColumnNames.Add("OrderTypeId"); radGridView1.Relations.Add(relation); GridViewTemplate shippersTemplate = new GridViewTemplate(); shippersTemplate.Caption = "Shippers"; radGridView1.MasterTemplate.Templates.Add(shippersTemplate); ((IDbSet <Shipper>) this.data.Shippers.All()).Load(); shippersTemplate.DataSource = ((IDbSet <Shipper>) this.data.Shippers.All()).Local.ToBindingList(); shippersTemplate.Columns["OrderType"].IsVisible = false; shippersTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation2 = new GridViewRelation(radGridView1.MasterTemplate); relation2.ChildTemplate = shippersTemplate; relation2.RelationName = "OrderTypesShippers"; relation2.ParentColumnNames.Add("OrderTypeId"); relation2.ChildColumnNames.Add("OrderTypeId"); radGridView1.Relations.Add(relation2); }
private void CreateBoundHierarchy() { using (this.radGridView1.DeferRefresh()) { this.radGridView1.MasterTemplate.Reset(); this.radGridView1.TableElement.RowHeight = 20; this.radGridView1.DataSource = nwindDataSet.Suppliers; this.radGridView1.MasterTemplate.Columns["CompanyName"].HeaderText = "Company Name"; this.radGridView1.MasterTemplate.Columns["ContactName"].HeaderText = "Contact Name"; this.radGridView1.MasterTemplate.Columns["SupplierID"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["Fax"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["ContactTitle"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["Region"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["City"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["PostalCode"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["HomePage"].IsVisible = false; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTemplate template = new GridViewTemplate(); template.DataSource = nwindDataSet.Products; this.radGridView1.Templates.Add(template); template.Columns["ProductName"].HeaderText = "Product Name"; template.Columns["QuantityPerUnit"].HeaderText = "Quantity Per Unit"; template.Columns["QuantityPerUnit"].TextAlignment = ContentAlignment.MiddleCenter; template.Columns["UnitPrice"].HeaderText = "Unit Price"; template.Columns["UnitPrice"].FormatString = "${0:F2}"; template.Columns["ProductID"].IsVisible = false; template.Columns["SupplierID"].IsVisible = false; template.Columns["CategoryID"].IsVisible = false; template.Columns["UnitsInStock"].IsVisible = false; template.Columns["UnitsOnOrder"].IsVisible = false; template.Columns["ReorderLevel"].IsVisible = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate, template); relation.RelationName = "SuppliersProducts"; relation.ParentColumnNames.Add("SupplierID"); relation.ChildColumnNames.Add("SupplierID"); this.radGridView1.Relations.Add(relation); } }
void LoadPerformanceTable() { Random r = new Random(); DataTable chartTable = new DataTable(); chartTable.Columns.Add("EmployeeID", typeof(int)); for (int i = 0; i < 12; i++) { chartTable.Columns.Add("Month" + (i + 1), typeof(int)); } foreach (DataRow row in this.northwindDataSet.Employees.Rows) { DataRow dataRow = chartTable.NewRow(); dataRow["EmployeeID"] = row["EmployeeID"]; for (int i = 0; i < 12; i++) { dataRow[i + 1] = r.Next(1000) * 10; } chartTable.Rows.Add(dataRow); } GridViewTemplate template2 = new GridViewTemplate(); template2.Caption = "Performance"; template2.DataSource = chartTable; template2.AllowRowResize = false; template2.ShowColumnHeaders = false; template2.ShowRowHeaderColumn = false; template2.Columns[0].Width = 600; for (int i = 1; i < template2.Columns.Count; i++) { template2.Columns[i].IsVisible = false; } this.radGridView1.Templates.Add(template2); GridViewRelation relation2 = new GridViewRelation(this.radGridView1.MasterTemplate); relation2.ChildTemplate = template2; relation2.ParentColumnNames.Add("EmployeeID"); relation2.ChildColumnNames.Add("EmployeeID"); this.radGridView1.Relations.Add(relation2); }
protected override void ProcessDragDrop(Point dropLocation, ISupportDrag dragObject) { object dataContext = dragObject.GetDataContext(); if (dataContext is GridViewDataColumn) { GridViewColumn gridViewColumn = dataContext as GridViewColumn; GroupDescriptor groupDescription = new GroupDescriptor(); groupDescription.GroupNames.Add(new SortDescriptor(gridViewColumn.Name, ListSortDirection.Ascending)); if (TemplateGroupsElement.RaiseGroupByChanging(gridViewColumn.OwnerTemplate, groupDescription, NotifyCollectionChangedAction.Add)) { return; } gridViewColumn.OwnerTemplate.DataView.GroupDescriptors.Add(groupDescription); TemplateGroupsElement.RaiseGroupByChanged(gridViewColumn.OwnerTemplate, groupDescription, NotifyCollectionChangedAction.Add); } else { if (!(dataContext is GroupFieldDragDropContext)) { return; } GroupFieldDragDropContext fieldDragDropContext = dataContext as GroupFieldDragDropContext; SortDescriptor sortDescription = fieldDragDropContext.SortDescription; GridViewTemplate viewTemplate = fieldDragDropContext.ViewTemplate; GroupDescriptor groupDescription1 = fieldDragDropContext.GroupDescription; if (TemplateGroupsElement.RaiseGroupByChanging(viewTemplate, groupDescription1, NotifyCollectionChangedAction.Batch)) { return; } groupDescription1.GroupNames.Remove(sortDescription); GroupDescriptor groupDescription2 = new GroupDescriptor(); groupDescription2.GroupNames.Add(sortDescription); viewTemplate.GroupDescriptors.Add(groupDescription2); if (groupDescription1.GroupNames.Count == 0) { viewTemplate.DataView.GroupDescriptors.Remove(groupDescription1); } TemplateGroupsElement.RaiseGroupByChanged(viewTemplate, groupDescription2, NotifyCollectionChangedAction.Batch); } }
public GridViewCellInfo this[int index] { get { GridViewTemplate viewTemplate = this.rowInfo.ViewTemplate; if (viewTemplate == null) { return((GridViewCellInfo)null); } if (index < 0 || index >= viewTemplate.Columns.Count) { return((GridViewCellInfo)null); } GridViewColumn column = (GridViewColumn)viewTemplate.Columns[index]; if (column == null) { return((GridViewCellInfo)null); } return(this.GetCellInfo(column)); } }
GridViewEventResult IGridViewEventListener.ProcessEvent( GridViewEvent eventData) { GridViewFilterDescriptorCollection sender1 = eventData.Sender as GridViewFilterDescriptorCollection; GridViewTemplate sender2 = eventData.Sender as GridViewTemplate; GridViewDataColumn sender3 = eventData.Sender as GridViewDataColumn; if (sender2 == this.ViewTemplate && eventData.Info.Id == KnownEvents.ViewChanged) { this.ProcessViewChanged(eventData.Arguments[0] as DataViewChangedEventArgs); } else if (sender3 != null && sender3.OwnerTemplate == this.ViewTemplate && (eventData.Info.Id == KnownEvents.PropertyChanged && sender3.FilterDescriptor == null)) { this.CreateFilterDescriptor(sender3, this.GetDefaultFilterOperator(sender3)); } else if (sender1 != null && sender1.Owner == this.ViewTemplate && eventData.Info.Id == KnownEvents.CollectionChanged) { this.ProcessFilterDescriptorCollectionChanged(eventData.Arguments[0] as NotifyCollectionChangedEventArgs); } return((GridViewEventResult)null); }
private void ProcessGroupFieldDrop(Point dropLocation, GroupFieldDragDropContext context) { SortDescriptor sortDescription = context.SortDescription; GridViewTemplate viewTemplate = context.ViewTemplate; GroupDescriptor groupDescription = context.GroupDescription; if (TemplateGroupsElement.RaiseGroupByChanging(viewTemplate, groupDescription, NotifyCollectionChangedAction.Batch) || this.ProcessGroupFieldDropOverride(dropLocation, context)) { return; } groupDescription.GroupNames.Remove(sortDescription); GroupDescriptor groupDescriptor = new GroupDescriptor(); groupDescriptor.GroupNames.Add(sortDescription); RadGridViewDragDropService.InsertOnLeftOrRight <GroupDescriptor>(RadGridViewDragDropService.IsDroppedAtLeft(dropLocation, this.Size.Width), (Collection <GroupDescriptor>) this.description.Owner, this.description, groupDescriptor); if (groupDescription.GroupNames.Count == 0) { viewTemplate.DataView.GroupDescriptors.Remove(groupDescription); } TemplateGroupsElement.RaiseGroupByChanged(viewTemplate, groupDescriptor, NotifyCollectionChangedAction.Batch); }
private GridViewTemplate SetupChildForUnbound() { GridViewTemplate template = new GridViewTemplate(); template.AllowAddNewRow = true; GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Name"); textBoxColumn.HeaderText = "Name"; template.Columns.Add(textBoxColumn); GridViewDecimalColumn productNumberColumn = new GridViewDecimalColumn("Product Number"); productNumberColumn.HeaderText = "Product Number"; productNumberColumn.DecimalPlaces = 0; productNumberColumn.FormatString = "#{0}"; template.Columns.Add(productNumberColumn); GridViewDecimalColumn decimalChildColumn1 = new GridViewDecimalColumn("Quantity"); decimalChildColumn1.HeaderText = "Quantity"; template.Columns.Add(decimalChildColumn1); GridViewDecimalColumn decimalChildColumn2 = new GridViewDecimalColumn("Discount"); decimalChildColumn2.HeaderText = "Discount"; decimalChildColumn2.FormatString = "{0:F2}%"; template.Columns.Add(decimalChildColumn2); GridViewDecimalColumn decimalChildColumn3 = new GridViewDecimalColumn("Total"); decimalChildColumn3.HeaderText = "Total"; decimalChildColumn3.FormatString = "${0}"; template.Columns.Add(decimalChildColumn3); this.radGridView1.Templates.Add(template); LoadDataForUnbound(); template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; return(template); }
private void SetupMasterForAutoGenerateHierarchy() { this.radGridView1.MasterTemplate.Columns["CompanyName"].HeaderText = "Company Name"; this.radGridView1.MasterTemplate.Columns["ContactName"].HeaderText = "Contact Name"; this.radGridView1.MasterTemplate.Columns["CustomerID"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["ContactTitle"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["Region"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["PostalCode"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["Country"].IsVisible = false; this.radGridView1.MasterTemplate.Columns["Fax"].IsVisible = false; this.radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTemplate template = this.radGridView1.MasterTemplate.Templates[0]; template.Columns["OrderID"].HeaderText = "Order ID"; template.Columns["ShipAddress"].HeaderText = "Ship Address"; template.Columns["OrderDate"].HeaderText = "Order Date"; template.Columns["OrderDate"].TextAlignment = ContentAlignment.MiddleRight; template.Columns["OrderDate"].FormatString = "{0: ddd, MM/dd}"; template.Columns["CustomerID"].IsVisible = false; template.Columns["EmployeeID"].IsVisible = false; template.Columns["RequiredDate"].IsVisible = false; template.Columns["ShippedDate"].IsVisible = false; template.Columns["ShipVia"].IsVisible = false; template.Columns["ShipName"].IsVisible = false; template.Columns["ShipCity"].IsVisible = false; template.Columns["ShipRegion"].IsVisible = false; template.Columns["ShipPostalCode"].IsVisible = false; template.Columns["ShipCity"].IsVisible = false; template.Columns["ShipName"].IsVisible = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template = this.radGridView1.MasterTemplate.Templates[0].Templates[0]; template.Columns["UnitPrice"].FormatString = "${0:F2}"; template.Columns["Discount"].FormatString = "{0:0.00%;0.00%;none}"; template.Columns["ProductID"].IsVisible = false; template.Columns["OrderID"].HeaderText = "Order ID"; template.Columns["UnitPrice"].HeaderText = "Unit Price"; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; }
private List <GridViewColumn> GetColumnsForExpression( GridViewTemplate gridTemplate, ExpressionNode expression, out bool containsAggregate) { containsAggregate = false; List <GridViewColumn> gridViewColumnList = new List <GridViewColumn>(); Stack <ExpressionNode> expressionNodeStack = new Stack <ExpressionNode>(); expressionNodeStack.Push(expression); while (expressionNodeStack.Count > 0) { ExpressionNode expressionNode1 = expressionNodeStack.Pop(); if (expressionNode1 != null) { NameNode nameNode = expressionNode1 as NameNode; if (nameNode != null && !nameNode.IsConst) { GridViewColumn column = (GridViewColumn)gridTemplate.Columns[nameNode.Name]; if (column != null && !gridViewColumnList.Contains(column)) { gridViewColumnList.Add(column); } } else if (expressionNode1 is AggregateNode) { containsAggregate = true; } IEnumerable <ExpressionNode> childNodes = expressionNode1.GetChildNodes(); if (childNodes != null) { foreach (ExpressionNode expressionNode2 in childNodes) { expressionNodeStack.Push(expressionNode2); } } } } return(gridViewColumnList); }
public static void DispatchEvent( GridViewTemplate template, GridViewEvent eventData, bool postUI) { if (template == null) { throw new ArgumentNullException("Template"); } MasterGridViewTemplate masterTemplate = template.MasterTemplate; if (masterTemplate == null) { return; } GridViewSynchronizationService synchronizationService = masterTemplate.SynchronizationService; if (synchronizationService == null) { return; } if (eventData.Info.Type == GridEventType.Both && postUI) { KnownEvents id = eventData.Info.Id; bool critical = eventData.Info.Critical; object[] arguments = eventData.Arguments; object sender = eventData.Sender; object originator = eventData.Originator; GridViewEventInfo eventInfo1 = new GridViewEventInfo(id, GridEventType.Data, GridEventDispatchMode.Send, critical); GridViewEvent gridEvent1 = new GridViewEvent(sender, originator, arguments, eventInfo1); GridViewEventInfo eventInfo2 = new GridViewEventInfo(id, GridEventType.UI, GridEventDispatchMode.Post, critical); GridViewEvent gridEvent2 = new GridViewEvent(sender, originator, arguments, eventInfo2); synchronizationService.DispatchEvent(gridEvent1); synchronizationService.DispatchEvent(gridEvent2); } else { synchronizationService.DispatchEvent(eventData); } }
private GridViewTemplate CreateOrderDetailsTemplate() { GridViewTemplate orderDetailsTemplate = new GridViewTemplate(); OrdersGrid.Templates.Add(orderDetailsTemplate); GridViewTextBoxColumn orderColumn = new GridViewTextBoxColumn("vehicle_number"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("order_number"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("model_name"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("engine_designation"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("colour"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("expected_delivery_date"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("actual_delivery_date"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("Model.base_cost"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("Model.average_lead_time"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("Engine.fuel_type"); orderDetailsTemplate.Columns.Add(orderColumn); orderColumn = new GridViewTextBoxColumn("Trim.additional_cost"); orderDetailsTemplate.Columns.Add(orderColumn); orderDetailsTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; var trimDetailsTemplate = CreateTrimDetailsTemplate(orderDetailsTemplate); GridViewRelation relation = new GridViewRelation(orderDetailsTemplate, trimDetailsTemplate); relation.RelationName = "TrimEquipment"; OrdersGrid.Relations.Add(relation); return(orderDetailsTemplate); }
private void ProcessFilterDescriptors( GridViewTemplate template, FilterDescriptorCollection filterDescriptorCollection) { foreach (FilterDescriptor filterDescriptor1 in (Collection <FilterDescriptor>)filterDescriptorCollection) { CompositeFilterDescriptor filterDescriptor2 = filterDescriptor1 as CompositeFilterDescriptor; if (filterDescriptor2 != null) { this.ProcessFilterDescriptors(template, filterDescriptor2.FilterDescriptors); } else { GridViewDataColumn[] columnByFieldName = template.Columns.GetColumnByFieldName(filterDescriptor1.PropertyName); if (columnByFieldName != null && columnByFieldName.Length > 0) { GridViewDataColumn gridViewDataColumn = columnByFieldName[0]; filterDescriptor1.Value = RadDataConverter.Instance.Parse((IDataConversionInfoProvider)gridViewDataColumn, filterDescriptor1.Value); } } } }
private void SetUpGrid() { ((IDbSet<OrderType>)this.data.OrderTypes.All()).Load(); this.radGridView1.DataSource = ((IDbSet<OrderType>)this.data.OrderTypes.All()).Local.ToBindingList(); this.radGridView1.Columns["Orders"].IsVisible = false; this.radGridView1.Columns["Shippers"].IsVisible = false; this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewTemplate ordersTemplate = new GridViewTemplate(); ordersTemplate.Caption = "Orders"; radGridView1.MasterTemplate.Templates.Add(ordersTemplate); ((IDbSet<Order>)this.data.Orders.All()).Load(); ordersTemplate.DataSource = ((IDbSet<Order>)this.data.Orders.All()).Local.ToBindingList(); ordersTemplate.Columns["OrderType"].IsVisible = false; ordersTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate); relation.ChildTemplate = ordersTemplate; relation.RelationName = "OrderTypesOrders"; relation.ParentColumnNames.Add("OrderTypeId"); relation.ChildColumnNames.Add("OrderTypeId"); radGridView1.Relations.Add(relation); GridViewTemplate shippersTemplate = new GridViewTemplate(); shippersTemplate.Caption = "Shippers"; radGridView1.MasterTemplate.Templates.Add(shippersTemplate); ((IDbSet<Shipper>)this.data.Shippers.All()).Load(); shippersTemplate.DataSource = ((IDbSet<Shipper>)this.data.Shippers.All()).Local.ToBindingList(); shippersTemplate.Columns["OrderType"].IsVisible = false; shippersTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation2 = new GridViewRelation(radGridView1.MasterTemplate); relation2.ChildTemplate = shippersTemplate; relation2.RelationName = "OrderTypesShippers"; relation2.ParentColumnNames.Add("OrderTypeId"); relation2.ChildColumnNames.Add("OrderTypeId"); radGridView1.Relations.Add(relation2); }
private GridViewTemplate CreateChildTemplate() { GridViewTemplate template = new GridViewTemplate(); template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; template.Columns.Add(new GridViewTextBoxColumn { Name = "Id", HeaderText = "ID" }); template.Columns.Add(new GridViewTextBoxColumn { Name = "SampleNumber", HeaderText = "Sample Number" }); template.Columns.Add(new GridViewTextBoxColumn { Name = "ParentId", HeaderText = "Parent Id" }); return(template); }
private void CreateBoundHierarchy() { var deliveryBiz = new DeliveryBiz(); using (this.radGridView.DeferRefresh()) { this.radGridView.MasterTemplate.Reset(); this.radGridView.AutoGenerateColumns = true; this.radGridView.AllowCellContextMenu = false; this.radGridView.ReadOnly = true; this.radGridView.TableElement.RowHeight = 20; this.radGridView.DataSource = deliveryBiz.GetTemplateData(); this.radGridView.MasterTemplate.Columns["Vehicle"].HeaderText = "Xe"; this.radGridView.MasterTemplate.Columns["DeliveryNo"].HeaderText = "Số giao hàng"; this.radGridView.MasterTemplate.Columns["DeliveryDate"].HeaderText = "Ngày giao"; this.radGridView.MasterTemplate.Columns["StartTime"].HeaderText = "Giờ giao"; this.radGridView.MasterTemplate.Columns["Status"].HeaderText = "Tình trạng"; this.radGridView.MasterTemplate.Columns["Id"].IsVisible = false; this.radGridView.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; var orderBiz = new OrderBiz(); GridViewTemplate template = new GridViewTemplate(); template.AutoGenerateColumns = true; template.AllowAddNewRow = false; template.AllowCellContextMenu = false; template.ReadOnly = true; template.DataSource = orderBiz.GetTemplateData(); this.radGridView.Templates.Add(template); template.Columns["OrderNo"].HeaderText = "Mã đơn hàng"; template.Columns["Status"].HeaderText = "Tình trạng"; template.Columns["Customer"].HeaderText = "Khách hàng"; template.Columns["DeliveryDate"].HeaderText = "Ngày giao"; template.Columns["DeliveryInternal"].HeaderText = "Hình thức vận chuyển"; template.Columns["SendMessage"].HeaderText = "Tin nhắn"; template.Columns["SendEmail"].HeaderText = "Email"; template.Columns["SendReport"].HeaderText = "Thông báo"; template.Columns["Id"].IsVisible = false; template.Columns["ParentId"].IsVisible = false; template.Columns["Recipient"].IsVisible = false; template.Columns["CustomerId"].IsVisible = false; template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; GridViewRelation relation = new GridViewRelation(radGridView.MasterTemplate, template); relation.RelationName = "SuppliersProducts"; relation.ParentColumnNames.Add("Id"); relation.ChildColumnNames.Add("ParentId"); this.radGridView.Relations.Add(relation); FormatCell(); } }
/// <summary> /// Loads actions definition. /// </summary> /// <param name="actions">Configuration of the actions</param> private void LoadActionsDefinition(UniGridActions actions) { // Custom template field of the grid view TemplateField actionsColumn = new TemplateField(); // Ensure width of the column if (!String.IsNullOrEmpty(actions.Width)) { actionsColumn.ItemStyle.Width = new Unit(actions.Width); } // Add object menu if possible if ((actions.Actions.Count > 0 && !(actions.Actions.FirstOrDefault() is EmptyAction)) && ShowObjectMenu && UniGridFunctions.ShowUniGridObjectContextMenu(CMSObjectHelper.GetReadOnlyObject(ObjectType))) { actions.Actions.RemoveAll(a => a is EmptyAction); // Check if object menu already contained var menus = from action in actions.Actions.OfType<Action>() where (action.Name.ToLower() == "#objectmenu") || (!String.IsNullOrEmpty(action.ContextMenu)) select action; // Add object menu of necessary if ((menus.Count() == 0) && !IsLiveSite) { Action action = new Action("#objectmenu"); action.ExternalSourceName = "#objectmenu"; actions.Actions.Add(action); } } // Show header? if (actions.ShowHeader) { if (ShowActionsMenu && string.IsNullOrEmpty(actions.ContextMenu)) { actions.ContextMenu = DEFAULT_ACTIONS_MENU; actions.Caption = "General.OtherActions"; } // Fill in the custom template field GridViewTemplate headerTemplate = new GridViewTemplate(ListItemType.Header, this, actions, GetString("unigrid.actions"), ImageDirectoryPath, DefaultImageDirectoryPath, Page); headerTemplate.ContextMenuParent = plcContextMenu; headerTemplate.CheckRelative = CheckRelative; actionsColumn.HeaderTemplate = headerTemplate; if (ShowActionsMenu) { if (actions.Actions.FirstOrDefault() is EmptyAction) { actionsColumn.HeaderStyle.CssClass = "EmptyAC"; } else { actionsColumn.HeaderStyle.CssClass = "AC"; } } } GridViewTemplate actionsTemplate = new GridViewTemplate(ListItemType.Item, this, actions, null, ImageDirectoryPath, DefaultImageDirectoryPath, Page); actionsTemplate.OnExternalDataBound += RaiseExternalDataBound; actionsTemplate.ContextMenuParent = plcContextMenu; actionsTemplate.CheckRelative = CheckRelative; actionsColumn.ItemTemplate = actionsTemplate; if (!IsLiveSite) { actionsColumn.ItemStyle.CssClass = "NW UniGridActions"; } else { actionsColumn.ItemStyle.CssClass = "UniGridActions"; actionsColumn.ItemStyle.Wrap = false; } // CSS class name string cssClass = actions.CssClass; if (cssClass != null) { actionsColumn.HeaderStyle.CssClass += " " + cssClass; actionsColumn.ItemStyle.CssClass += " " + cssClass; actionsColumn.FooterStyle.CssClass += " " + cssClass; } // Add custom column to grid view UniGridView.Columns.Add(actionsColumn); }
private void Form1_Load(object sender, EventArgs e) { RadGridLocalizationProvider.CurrentProvider = new MyRuRadGridLocalizationProvider(); this.db.Автомобили.Load(); this.radGridView1.DataSource = this.db.Автомобили.Local.ToBindingList(); this.radGridView1.Columns[0].Width = 30; this.radGridView1.Columns[0].HeaderText = "№"; this.radGridView1.Columns[0].ReadOnly = true; this.radGridView1.Columns[1].Width = 100; this.radGridView1.Columns[2].Width = 100; this.radGridView1.Columns[3].Width = 150; this.radGridView1.Columns[4].Width = 100; this.radGridView1.Columns[5].Width = 150; this.radGridView1.Columns[6].Width = 150; this.radGridView1.Columns[7].Width = 150; this.radGridView1.Columns[8].Width = 150; this.radGridView1.Columns[9].IsVisible = false; this.db.Цвет.Load(); comboColumn = new GridViewComboBoxColumn(radGridView1.Columns[9].Name); comboColumn.DataSource = this.db.Цвет.Local.ToBindingList(); comboColumn.Width = 100; comboColumn.ValueMember = "id"; comboColumn.DisplayMember = "Наименование"; comboColumn.FieldName = radGridView1.Columns[9].Name; this.radGridView1.Columns.Add(comboColumn); radGridView1.Columns.Move(25, 9); this.radGridView1.Columns[11].IsVisible = false; this.radGridView1.Columns[11].Width = 100; this.radGridView1.Columns[12].Width = 80; this.radGridView1.Columns[13].Width = 80; this.radGridView1.Columns[14].Width = 80; this.radGridView1.Columns[15].HeaderText = "Нач.Гарантии"; this.radGridView1.Columns[15].Width = 80; this.radGridView1.Columns[16].HeaderText = "Валюта"; this.db.Валюты.Load(); comboColumnVal = new GridViewComboBoxColumn(radGridView1.Columns[16].Name); comboColumnVal.DataSource = this.db.Валюты.Local.ToBindingList(); comboColumnVal.Width = 100; comboColumnVal.ValueMember = "id"; comboColumnVal.DisplayMember = "Наименование"; comboColumnVal.FieldName = radGridView1.Columns[16].Name; this.radGridView1.Columns.Add(comboColumnVal); radGridView1.Columns.Move(oldIndex: 26, newIndex: 16); this.radGridView1.Columns[17].IsVisible = false; this.radGridView1.Columns[18].Width = 80; this.radGridView1.Columns[18].HeaderText = "Кон.Гарантии"; this.radGridView1.Columns[19].Width = 80; this.radGridView1.Columns[19].HeaderText = "Ориг.VIN"; this.radGridView1.Columns[20].HeaderText = "Дата Регистр."; this.radGridView1.Columns[20].Width = 80; radGridView1.Columns[21].IsVisible = false; radGridView1.Columns[22].IsVisible = false; radGridView1.Columns[23].IsVisible = false; radGridView1.Columns[24].IsVisible = false; radGridView1.Columns[25].IsVisible = false; radGridView1.Columns[26].IsVisible = false; //добавление связанной таблицы Тип Салона var Salon = new GridViewTemplate(); this.db.ТипСалона.Load(); Salon.DataSource = this.db.ТипСалона.Local.ToBindingList(); Salon.Caption = "Тип Салона"; Salon.Columns[1].Width = 200; Salon.Columns[0].IsVisible = false; Salon.Columns[2].IsVisible = false; Salon.Columns[3].IsVisible = false; this.radGridView1.MasterTemplate.Templates.Add(Salon); GridViewRelation relationSalon = new GridViewRelation(this.radGridView1.MasterTemplate); relationSalon.ChildTemplate = Salon; relationSalon.RelationName = "Тип Салона"; relationSalon.ParentColumnNames.Add("id"); relationSalon.ChildColumnNames.Add("ID_Авто"); this.radGridView1.Relations.Add(relationSalon); //добавление связанной таблицы Тип Комплектации GridViewTemplate complect = new GridViewTemplate(); this.db.ВариантыКомплектации.Load(); complect.DataSource = this.db.ВариантыКомплектации.Local.ToBindingList(); complect.Caption = "Варианты комплектации"; complect.Columns[0].IsVisible = false; complect.Columns[7].IsVisible = false; complect.Columns[8].IsVisible = false; complect.Columns[9].IsVisible = false; complect.Columns[10].IsVisible = false; complect.Columns[11].IsVisible = false; complect.Columns[2].Width = 200; complect.Columns[3].Width = 100; complect.Columns[4].Width = 100; complect.Columns[5].Width = 100; complect.Columns[6].Width = 200; this.radGridView1.MasterTemplate.Templates.Add(complect); GridViewRelation relationcomplect = new GridViewRelation(this.radGridView1.MasterTemplate); relationcomplect.ChildTemplate = complect; relationcomplect.RelationName = "Варианты комплектации"; relationcomplect.ParentColumnNames.Add("id"); relationcomplect.ChildColumnNames.Add("ID_Авто"); this.radGridView1.Relations.Add(relationcomplect); //добавление связанной таблицы ТипКузова GridViewTemplate Kuzov = new GridViewTemplate(); this.db.ТипКузова.Load(); Kuzov.DataSource = this.db.ТипКузова.Local.ToBindingList(); Kuzov.Caption = "Тип Кузова"; Kuzov.Columns[1].Width = 200; Kuzov.Columns[0].IsVisible = false; Kuzov.Columns[2].IsVisible = false; Kuzov.Columns[3].IsVisible = false; Kuzov.Columns[4].IsVisible = false; complect.Templates.Add(Kuzov); GridViewRelation relationKuzov = new GridViewRelation(complect); relationKuzov.ChildTemplate = Kuzov; relationKuzov.RelationName = "Тип Кузова"; relationKuzov.ParentColumnNames.Add("id"); relationKuzov.ParentColumnNames.Add("id_Авто"); relationKuzov.ChildColumnNames.Add("ID_Комплект"); relationKuzov.ChildColumnNames.Add("id_Авто"); this.radGridView1.Relations.Add(relationKuzov); //добавление связанной таблицы ТипКПП GridViewTemplate template = new GridViewTemplate(); this.db.ТипКПП.Load(); template.DataSource = this.db.ТипКПП.Local.ToBindingList(); template.Caption = "Тип КПП"; template.Columns[0].IsVisible = false; template.Columns[2].IsVisible = false; template.Columns[1].Width = 200; template.Columns[3].IsVisible = false; template.Columns[4].IsVisible = false; complect.Templates.Add(template); GridViewRelation relation = new GridViewRelation(complect); relation.ChildTemplate = template; relation.RelationName = "Тип КПП"; relation.ParentColumnNames.Add("id"); relation.ParentColumnNames.Add("id_Авто"); relation.ChildColumnNames.Add("ID_Комплект"); relation.ChildColumnNames.Add("id_Авто"); this.radGridView1.Relations.Add(relation); //типы двигателей var dvig_komplect = new GridViewTemplate(); this.db.ТипыДвигателей.Load(); dvig_komplect.DataSource = this.db.ТипыДвигателей.Local.ToBindingList(); dvig_komplect.Caption = "Типы Двигателя"; complect.Templates.Add(dvig_komplect); dvig_komplect.Columns[1].Width = 200; dvig_komplect.Columns[2].Width = 200; dvig_komplect.Columns[0].IsVisible = false; dvig_komplect.Columns[3].IsVisible = false; dvig_komplect.Columns[4].IsVisible = false; dvig_komplect.Columns[5].IsVisible = false; GridViewRelation relationdvig_com = new GridViewRelation(complect); relationdvig_com.ChildTemplate = dvig_komplect; relationdvig_com.RelationName = "Тип Двигателя"; relationdvig_com.ParentColumnNames.Add("id"); relationdvig_com.ParentColumnNames.Add("id_Авто"); relationdvig_com.ChildColumnNames.Add("ID_Комплект"); relationdvig_com.ChildColumnNames.Add("id_Авто"); this.radGridView1.Relations.Add(relationdvig_com); // }