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); }
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); }