Esempio n. 1
0
 protected virtual object GetCascadeFromValue(Widget parent)
 {
     return(EditorUtils.GetValue(parent));
 }
Esempio n. 2
0
        public TWidget AddEqualityFilter <TWidget>(string field, string title    = null, 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(DetermineText(title ?? field, pre => pre + field) ?? "")
                              .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);

            Action submitHandler = () =>
            {
                if (quickFilter.HasClass("ignore"))
                {
                    return;
                }

                var request = (ListRequest)view.Params;
                request.EqualityFilter = request.EqualityFilter ?? new JsDictionary <string, object>();

                var  value  = EditorUtils.GetValue(widget);
                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,
                        Widget         = widget,
                        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);
            });

            submitHandlers += submitHandler;
            widget.Element.Bind("remove." + this.uniqueName, x =>
            {
                submitHandlers -= submitHandler;
            });

            return(widget);
        }
Esempio n. 3
0
 public static jQueryObject SetReadOnly(jQueryObject elements, bool isReadOnly)
 {
     return(EditorUtils.SetReadOnly(elements, isReadOnly));
 }
Esempio n. 4
0
 public static void SetReadOnly(Widget widget, bool isReadOnly)
 {
     EditorUtils.SetReadOnly(widget, isReadOnly);
 }
Esempio n. 5
0
 public static void SetRequired(Widget widget, bool isRequired)
 {
     EditorUtils.SetRequired(widget, isRequired);
 }
Esempio n. 6
0
 public static void SaveEditorValue(Widget editor, PropertyItem item, dynamic target)
 {
     EditorUtils.SaveValue(editor, item, target);
 }