public void Search() { this.rowsDiv.Children().Children("div.v").Children("span.error").Remove(); var filterLines = new List <FilterLine>(); string errorText = null; jQueryObject row = null; for (int i = 0; i < rowsDiv.Children().Length; i++) { try { row = rowsDiv.Children().Eq(i); var filtering = GetFilteringFor(row); if (filtering == null) { continue; } var field = GetFieldFor(row); var op = row.Children("div.o").Find("input.op-select").GetWidget <OperatorSelect>().Value; if (op == null || op.Length == 0) { throw new ArgumentOutOfRangeException("operator", Q.Text("Controls.FilterPanel.InvalidOperator")); } FilterLine line = new FilterLine(); line.Field = field.Name; line.Operator = op; line.IsOr = row.Children("div.l").Children("a.andor").HasClass("or"); line.LeftParen = row.Children("div.l").Children("a.leftparen").HasClass("active"); line.RightParen = row.Children("div.l").Children("a.rightparen").HasClass("active"); string displayText; filtering.Operator = op; line.Criteria = filtering.GetCriteria(out displayText); line.State = filtering.SaveState(); line.DisplayText = displayText; filterLines.Add(line); } catch (ArgumentException ex) { errorText = ex.Message; break; } } // if an error occured, display it, otherwise set current filters if (errorText != null) { J("<span/>").AddClass("error").Text(errorText).AppendTo(row.Children("div.v")); row.Children("div.v").Find("input:first").Focus(); return; } Store.Items.Clear(); Store.Items.AddRange(filterLines); Store.RaiseChanged(); }
private void Search() { List <FilterLine> filterLines = new List <FilterLine>(); string filterText = ""; string errorText = null; jQueryObject row = null; this.rowsDiv.Children().Children("div.v").Children("span.error").Remove(); bool inParens = false; for (int i = 0; i < rowsDiv.Children().Length; i++) { row = rowsDiv.Children().Eq(i); IFilterHandler handler = GetFilterHandlerFor(row); if (handler == null) { continue; } FilterField field = GetFieldFor(row); string op = row.Children("div.o").Children("select").GetValue(); if (op == null || op.Length == 0) { errorText = Q.Text("Controls.FilterPanel.InvalidOperator"); break; } FilterLine lineEx = new FilterLine(); lineEx.Field = field.Name; lineEx.Title = field.Title ?? field.Name; lineEx.Operator = op; lineEx.IsOr = row.Children("div.l").Children("a.andor").HasClass("or"); lineEx.LeftParen = row.Children("div.l").Children("a.leftparen").HasClass("active"); lineEx.RightParen = row.Children("div.l").Children("a.rightparen").HasClass("active"); handler.ToFilterLine(lineEx); if (lineEx.ValidationError != null) { errorText = lineEx.ValidationError; break; } FilterLine line = new FilterLine(); line.Field = lineEx.Field; line.Operator = lineEx.Operator; if (Script.IsValue(lineEx.Value)) { line.Value = lineEx.Value; } if (Script.IsValue(lineEx.Value2)) { line.Value2 = lineEx.Value2; } if (Script.IsValue(lineEx.Values) && lineEx.Values.Count > 0) { line.Values = lineEx.Values; } if (lineEx.LeftParen) { line.LeftParen = 1.As < bool > (); } if (lineEx.RightParen) { line.RightParen = 1.As < bool > (); } if (lineEx.IsOr) { line.IsOr = 1.As < bool > (); } filterLines.Add(line); if (inParens && (lineEx.RightParen || lineEx.LeftParen)) { filterText += ")"; inParens = false; } if (filterText.Length > 0) { filterText += " " + Q.Text("Controls.FilterPanel." + (lineEx.IsOr ? "Or" : "And")) + " "; } if (lineEx.LeftParen) { filterText += "("; inParens = true; } filterText += lineEx.DisplayText; } // if an error occured, display it, otherwise set current filters if (errorText != null) { J("<span/>").AddClass("error").Text(errorText).AppendTo(row.Children("div.v")); row.Children("div.v").Find("input:first").Focus(); return; } if (filterLines.Count == 0) { this.SetCurrentFilter(null, null); } else { this.SetCurrentFilter(filterLines, filterText); } }