public override void Apply(DataGridColumns dataGridColumns, ref DataGridRules rules) { DataGridRule dataGridRule = new DataGridRule(); DataGridColumn col = dataGridColumns[_filterDescriptor.PropertyName]; if ((col != null)) { dataGridRule.Table = col.Table; dataGridRule.Name = col.Name; dataGridRule.ExtendedFieldName = col.ExtendedFieldName; dataGridRule.AliasField = col.AliasField; dataGridRule.ExpressionDb = col.ExpressionDb; dataGridRule.Criterio = DataGridRule.TranslateFromFilter(_filterDescriptor.Operator); dataGridRule.CurrentFilterType = DataGridRule.FilterType.Data; if (_filterDescriptor.Operator == Telerik.WinControls.Data.FilterOperator.IsNull) { dataGridRule.Value = ""; } else { dataGridRule.Value = Convert.ToDateTime(_filterDescriptor.Value).ToString("yyyy-MM-dd"); } string filterValue = _filterDescriptor.Value as string; FilterOperator op = _filterDescriptor.Operator; UpdateRules(_filterDescriptor, dataGridRule, ref rules); } }
public override void Apply(DataGridColumns dataGridColumns, ref DataGridRules rules) { DataGridColumn col = dataGridColumns[_filterDescriptor.PropertyName]; if (col != null) { DataGridRule customGridRule = new DataGridRule(); customGridRule.Table = col.Table; customGridRule.Name = col.Name; customGridRule.ExtendedFieldName = col.ExtendedFieldName; customGridRule.AliasField = col.AliasField; customGridRule.ExpressionDb = col.ExpressionDb; customGridRule.Criterio = DataGridRule.TranslateFromFilter(_filterDescriptor.Operator); customGridRule.CurrentFilterType = DataGridRule.FilterType.Text; if (_filterDescriptor.Operator == Telerik.WinControls.Data.FilterOperator.IsNull) { customGridRule.Value = ""; } else { customGridRule.Value = _filterDescriptor.Value; } base.UpdateRules(_filterDescriptor, customGridRule, ref rules); } }
protected bool UpdateRules(FilterDescriptor filter, DataGridRule rule, ref DataGridRules rules) { bool needChange = false; string name = filter.Value as string; bool validOperator = (filter.Operator != FilterOperator.IsNull); DataGridRule tempGridRule = null; if (string.IsNullOrEmpty(name) && (validOperator)) { rules.Remove(rule.Name); } else { if (rules.Exists(rule.Name)) { tempGridRule = rules[rule.Name]; rule.Item = tempGridRule.Item; if (rule.Criterio != tempGridRule.Criterio) { needChange = true; } rules.Modify(rule); } else { rules.Add(rule); } } return(needChange); }
public override void Apply(DataGridColumns dataGridColumns, ref DataGridRules rules) { DataGridColumn dataGridColumn = dataGridColumns[_filterDescriptors.PropertyName]; DataGridRule dataGridRule; IDictionary <Type, DataGridRule.FilterType> kindOFilterTypes = new Dictionary <Type, DataGridRule.FilterType>(); kindOFilterTypes.Add(typeof(FilterDescriptor), DataGridRule.FilterType.Text); kindOFilterTypes.Add(typeof(DateFilterDescriptor), DataGridRule.FilterType.Data); DataGridRules dataGridRulesParts = new DataGridRules(); dataGridRule = new DataGridRule(); if (dataGridColumn != null) { int i = 0; foreach (var filterDescriptor in _filterDescriptors.FilterDescriptors) { dataGridRule.Table = dataGridColumn.Table; dataGridRule.Name = dataGridColumn.Name; dataGridRule.ExtendedFieldName = dataGridColumn.ExtendedFieldName; dataGridRule.AliasField = dataGridColumn.AliasField; dataGridRule.ExpressionDb = dataGridColumn.ExpressionDb; dataGridRule.Criterio = DataGridRule.TranslateFromFilter(_filterDescriptors.Operator); DataGridRule.FilterType type = kindOFilterTypes[filterDescriptor.GetType()]; bool isNull = (filterDescriptor.Operator == Telerik.WinControls.Data.FilterOperator.IsNull); switch (type) { case DataGridRule.FilterType.Text: { dataGridRule.Value = (isNull) ? "" : filterDescriptor.Value; break; } case DataGridRule.FilterType.Data: { dataGridRule.Value = (isNull) ? " " : Convert.ToDateTime(filterDescriptor.Value).ToString("yyyy-MM-dd"); break; } } bool validOperator = (filterDescriptor.Operator != FilterOperator.IsNull); string name = filterDescriptor.Value as string; if (!string.IsNullOrEmpty(name) || (!validOperator)) { dataGridRulesParts.Add(dataGridRule); i += 1; } } } DataGridRule tmpRule = dataGridRule; tmpRule.Table = dataGridColumn.Table; tmpRule.Name = dataGridColumn.Name; tmpRule.ExtendedFieldName = dataGridColumn.ExtendedFieldName; tmpRule.ExpressionDb = dataGridColumn.ExpressionDb; tmpRule.CurrentFilterType = DataGridRule.FilterType.Composed; tmpRule.Operador = (_filterDescriptors.LogicalOperator == FilterLogicalOperator.And) ? DataGridRule.OperatorRule.And : DataGridRule.OperatorRule.Or; tmpRule.Expresion = " " + (_filterDescriptors.NotOperator ? "NOT" : "") + "("; foreach (DataGridRule rlPart in tmpRule.Rules.Order()) { if (rlPart.Item > 0) { tmpRule.Expresion += tmpRule.OperadorVal; } tmpRule.Expresion += tmpRule.Rules.ComputeWhereClause(); } tmpRule.Expresion += ") "; if (tmpRule.Rules.Count() == 0) { rules.Remove(tmpRule.Name); } else if (rules.Exists(tmpRule.Name)) { tmpRule.Item = rules[tmpRule.Name].Item; rules.Modify(tmpRule); } else { rules.Add(tmpRule); } }
public abstract void Apply(DataGridColumns dataGridColumns, ref DataGridRules rules);