internal static bool RaiseGroupByChanging( GridViewTemplate template, GroupDescriptor groupDescription, NotifyCollectionChangedAction action) { GridGroupByExpression fromDescriptor = GridGroupByExpression.CreateFromDescriptor(groupDescription); GridViewCollectionChangingEventArgs args; if (action == NotifyCollectionChangedAction.Add || action == NotifyCollectionChangedAction.ItemChanged || action == NotifyCollectionChangedAction.Remove) { args = new GridViewCollectionChangingEventArgs(template, action, (object)fromDescriptor, 0, 0); } else { if (action != NotifyCollectionChangedAction.Batch) { throw new ArgumentException("Invalid action"); } IList newItems = (IList) new List <GridGroupByExpression>(); newItems.Add((object)fromDescriptor); args = new GridViewCollectionChangingEventArgs(template, action, newItems, (IList)template.GroupDescriptors, 0, 0, (PropertyChangingEventArgsEx)null); } template.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.GroupByChanging, (object)template, args); if (!args.Cancel) { template.EventDispatcher.SuspendEvent(EventDispatcher.GroupByChanging); template.EventDispatcher.SuspendEvent(EventDispatcher.GroupByChanged); template.MasterTemplate.SynchronizationService.BeginDispatch(); } return(args.Cancel); }
private void ParseGroupByFieldList(string fieldList, int pos, bool allowRelation) { this.GroupByFields.Clear(); if (string.IsNullOrEmpty(fieldList)) { return; } Match match; do { match = GridGroupByExpression.groupByFieldParser.Match(fieldList.Substring(pos)); if (!match.Success) { throw new FormatException(string.Format("Cannot parse \"{0}\". Verify the correctness of the string.", (object)fieldList)); } GridGroupByField groupByField = new GridGroupByField(); if (match.Groups["aggregate"].Success) { groupByField.SetAggregate(match.Groups["aggregate"].ToString()); } groupByField.SortOrder = !match.Groups["sortDirection"].Success || string.Compare("DESC", match.Groups["sortDirection"].Value) != 0 ? RadSortOrder.Ascending : RadSortOrder.Descending; if (!match.Groups["fieldName"].Success) { throw new FormatException("Could not parse field name. Please contact Telerik support"); } groupByField.FieldName = match.Groups["fieldName"].ToString(); GridGroupByExpression.UpdateGroupByReferences(this.selectFields, groupByField); this.groupByFields.Add(groupByField); pos += match.Length; }while (match.Groups["delimiter"].Success); }
public int IndexOf(string expression) { GridGroupByExpression groupByExpression = new GridGroupByExpression(expression); return(new SortDescriptorCollection() { Expression = groupByExpression.GroupByFields.ToString() }.Count < 1 ? -1 : -1); }
internal static GridGroupByExpression CreateFromDescriptor( GroupDescriptor descriptor) { GridGroupByExpression groupByExpression = new GridGroupByExpression(); foreach (SortDescriptor groupName in (Collection <SortDescriptor>)descriptor.GroupNames) { groupByExpression.GroupByFields.Add(new GridGroupByField(groupName.PropertyName)); } return(groupByExpression); }
private static void UpdateFieldNameAndAliasReferences( GridGroupByFieldCollection list, GridGroupByField groupByField) { GridGroupByExpression.UpdateReference(list, groupByField); GridGroupByField byName = list.FindByName(groupByField.FieldName); if (byName != null && (byName.IsFieldAliasSet && groupByField.IsFieldAliasSet && byName.Aggregate == groupByField.Aggregate ^ string.Compare(byName.FieldAlias, groupByField.FieldAlias) == 0)) { throw new FormatException("Same aggregates on same field should have same alias."); } }
private GridGroupByExpression CreateGridGroupByExpression( GroupDescriptor groupDescription) { GridGroupByExpression groupByExpression = new GridGroupByExpression(); for (int index = 0; index < groupDescription.GroupNames.Count; ++index) { groupByExpression.GroupByFields.Add(new GridGroupByField(groupDescription.GroupNames[index].PropertyName) { SortOrder = GridViewHelper.GetSortDirection(groupDescription.GroupNames[index].Direction) }); } return(groupByExpression); }
public GridViewDataGroupEventArgs(GridGroupByExpression expression, int groupCount) { this.expression = expression; this.groupCount = groupCount; if (this.groupCount > 0) { this.headerText = new string[groupCount]; this.rowCount = new int[groupCount]; } else { this.headerText = new string[0]; this.rowCount = new int[0]; } }
public void CopyFrom(GridGroupByExpression expression) { this.SelectFields.Clear(); this.GroupByFields.Clear(); foreach (GridGroupByField selectField in (Collection <GridGroupByField>)expression.SelectFields) { GridGroupByField gridGroupByField = new GridGroupByField(); gridGroupByField.CopyFrom(selectField); this.SelectFields.Add(gridGroupByField); } foreach (GridGroupByField groupByField in (Collection <GridGroupByField>)expression.GroupByFields) { GridGroupByField gridGroupByField = new GridGroupByField(); gridGroupByField.CopyFrom(groupByField); this.GroupByFields.Add(gridGroupByField); } }
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 int ParseSelectFieldList(string fieldList, int pos) { this.clearSelectedFieldsSilently = true; this.SelectFields.Clear(); this.clearSelectedFieldsSilently = false; if (string.IsNullOrEmpty(fieldList)) { return(-1); } Match match; do { match = GridGroupByExpression.selectFieldParser.Match(fieldList.Substring(pos)); if (!match.Success) { throw new FormatException(string.Format("Cannot parse \"{0}\". Verify the correctness of the string.", (object)fieldList)); } GridGroupByField groupByField = new GridGroupByField(); if (match.Groups["fieldAlias"].Success) { groupByField.FieldAlias = match.Groups["fieldAlias"].ToString(); } if (match.Groups["aggregate"].Success) { groupByField.SetAggregate(match.Groups["aggregate"].ToString()); } groupByField.FormatString = match.Groups["formatString"].Success ? match.Groups["formatString"].ToString() : (string)null; if (!match.Groups["fieldName"].Success) { throw new FormatException("Could not parse field name. Please contact Telerik support"); } groupByField.FieldName = match.Groups["fieldName"].ToString(); GridGroupByExpression.UpdateFieldNameAndAliasReferences(this.selectFields, groupByField); this.selectFields.Add(groupByField); pos += match.Length; if (!match.Groups["delimiter"].Success) { throw new Exception("Delimiter (,) or Group By clause expected"); } }while (match.Groups["delimiter"].Length == 1); return(pos); }
public bool ContainsSameGroupByField(GridGroupByExpression expression) { bool flag = false; foreach (GridGroupByField groupByField1 in (Collection <GridGroupByField>)expression.GroupByFields) { foreach (GridGroupByField groupByField2 in (Collection <GridGroupByField>) this.GroupByFields) { if (groupByField2.FieldName.ToUpper() == groupByField1.FieldName.ToUpper()) { flag = true; break; } } if (flag) { break; } } return(flag); }
public override bool Equals(object obj) { bool flag = false; if (obj is GridGroupByExpression) { GridGroupByExpression groupByExpression = (GridGroupByExpression)obj; if (groupByExpression.GroupByFields.Count == this.GroupByFields.Count) { for (int index = 0; index < this.GroupByFields.Count; ++index) { if (this.GroupByFields[index].FieldName == groupByExpression.GroupByFields[index].FieldName) { flag = true; } } if (this.GroupByFields.Count == 0) { flag = true; } } } return(flag); }
public bool IsSame(GridGroupByExpression expression) { foreach (GridGroupByField selectField1 in (Collection <GridGroupByField>)expression.SelectFields) { bool flag = false; foreach (GridGroupByField selectField2 in (Collection <GridGroupByField>) this.SelectFields) { if (selectField2.FieldName.ToLower() == selectField1.FieldName.ToLower()) { flag = true; break; } } if (!flag) { return(false); } } foreach (GridGroupByField groupByField1 in (Collection <GridGroupByField>)expression.GroupByFields) { bool flag = false; foreach (GridGroupByField groupByField2 in (Collection <GridGroupByField>) this.GroupByFields) { if (groupByField2.FieldName.ToLower() == groupByField1.FieldName.ToLower()) { flag = true; break; } } if (!flag) { return(false); } } return(true); }
private GroupDescriptor CreateGroupDescription(GridGroupByExpression expression) { return(new GroupDescriptor(expression.GroupByFields.ToString())); }
internal GridGroupByExpression Clone() { return(GridGroupByExpression.Parse(this.ToString())); }