public override object SaveState() { if (UseEditor()) { var target = new JsDictionary(); PropertyGrid.SaveEditorValue(editor, new PropertyItem { Name = "_" }, target); return(target); } return(base.SaveState()); }
protected override object GetEditorValue() { if (UseEditor()) { var target = new JsDictionary(); PropertyGrid.SaveEditorValue(editor, new PropertyItem { Name = "_" }, target); var value = target["_"]; if (value == null || (value is string && ((string)value).Trim().Length == 0)) { throw ArgumentNull(); } return(target["_"]); } return(base.GetEditorValue()); }
public TWidget AddEqualityFilter <TWidget>(string field, string title, object options = null, Action <QuickFilterArgs <TWidget> > handler = null, Action <jQueryObject> element = null, Action <TWidget> init = null) where TWidget : Widget { if (quickFiltersDiv == null) { J("<div/>").AddClass("clear").AppendTo(toolbar.Element); quickFiltersDiv = J("<div/>").AddClass("quick-filters-bar").AppendTo(toolbar.Element); } var quickFilter = J("<div class='quick-filter-item'><span class='quick-filter-label'></span></div>") .AppendTo(quickFiltersDiv) .Children().Text(title ?? "") .Parent(); var widget = Widget.Create <TWidget>( element: e => { if (!field.IsEmptyOrNull()) { e.Attribute("id", this.UniqueName + "_QuickFilter_" + field); } e.Attribute("placeholder", " "); e.AppendTo(quickFilter); if (element != null) { element(e); } }, options: options, init: init); submitHandlers += () => { var request = (ListRequest)view.Params; request.EqualityFilter = request.EqualityFilter ?? new JsDictionary <string, object>(); var obj = new JsDictionary <string, object>(); PropertyGrid.SaveEditorValue(widget, new PropertyItem { Name = "$$value$$", }, obj); var value = obj["$$value$$"]; bool active = Script.IsValue(value) && !string.IsNullOrEmpty(value.ToString()); if (handler != null) { var args = new QuickFilterArgs <TWidget> { Field = field, Request = request, EqualityFilter = request.EqualityFilter, Value = value, Active = active, Handled = true }; handler(args); quickFilter.ToggleClass("quick-filter-active", args.Active); if (!args.Handled) { request.EqualityFilter[field] = value; } } else { request.EqualityFilter[field] = value; quickFilter.ToggleClass("quick-filter-active", active); } }; widget.Change(e => { this.QuickFilterChange(e); }); return(widget); }