Exemple #1
0
        protected override void OnBeforeClientInit(Observable sender)
        {
            string fn = "this.getActivePageField().setValue(data.activePage);";

            this.On("change", new JFunction(fn, "el", "data"));

            string storeId = string.IsNullOrEmpty(this.StoreID) ? this.ProxyStoreID : this.StoreID;

            if (this.PageIndex > 1 && !string.IsNullOrEmpty(storeId))
            {
                Store store = ControlUtils.FindControl <Store>(this, storeId, true);
                if (store == null)
                {
                    throw new InvalidOperationException(string.Format("The Control '{0}' could not find the StoreID of '{1}'.", this.ID, storeId));
                }

                HandlerConfig options = new HandlerConfig();
                options.Single = true;
                string template = "{0}.store.on(\"load\",{1},{2},{3});";
                this.AddScript(template,
                               this.ClientID,
                               string.Concat("function(){", this.ClientID, ".changePage(", this.PageIndex, ");}"),
                               "this",
                               options.ToJsonString()
                               );
            }
        }
Exemple #2
0
 protected override void OnBeforeClientInit(Observable sender)
 {
     if (this.AutoPostBack)
     {
         HandlerConfig cfg = new HandlerConfig();
         cfg.Delay = 10;
         this.On("select", new JFunction(this.PostBackFunction), "this", cfg);
     }
 }
Exemple #3
0
        public HandlerConfig GetListenerConfig()
        {
            HandlerConfig cfg = new HandlerConfig();

            cfg.Scope  = this.Scope;
            cfg.Buffer = this.Buffer;
            cfg.Delay  = this.Delay;
            cfg.Single = this.Single;

            return(cfg);
        }
Exemple #4
0
        protected override void OnBeforeClientInit(Observable sender)
        {
            if (!this.ClientID.Equals(this.UniqueName))
            {
                this.CustomConfig.Add(new ConfigItem("uniqueName", this.UniqueName, ParameterMode.Value));
            }

            if (this.TriggerAutoPostBack)
            {
                this.PostBackArgument = "_index_";
                string replace = string.Concat("'", this.PostBackArgument, "'");
                this.On("triggerclick", new JFunction(this.PostBackFunction.Replace(replace, "index"), "el", "t", "index"));
            }


            if (this.AutoPostBack)
            {
                EventHandler handler = (EventHandler)Events[EventItemSelected];
                if (handler != null)
                {
                    this.PostBackArgument = "select";

                    this.On("select", new JFunction(this.PostBackFunction));
                }
                else
                {
                    HandlerConfig config = new HandlerConfig();
                    config.Delay = 10;

                    this.PostBackArgument = "change";
                    this.On("blur", new JFunction(this.PostBackFunction), "this", config);
                }
            }

            if (!string.IsNullOrEmpty(this.StoreID))
            {
                Store store = ControlUtils.FindControl <Store>(this, this.StoreID, true);
                if (store == null)
                {
                    throw new InvalidOperationException(string.Format("The Control '{0}' could not find the StoreID of '{1}'.", this.ID, this.StoreID));
                }
            }
            else
            {
                this.TriggerAction = TriggerAction.All;
                this.Mode          = DataLoadMode.Local;
            }

            if (!string.IsNullOrEmpty(this.SelectedItem.Value))
            {
                this.Value = this.SelectedItem.Value;
            }
        }
Exemple #5
0
        protected override void OnBeforeClientInit(Observable sender)
        {
            if (this.AutoPostBack)
            {
                EventHandler handler = (EventHandler)Events[EventSelectionChanged];
                if (handler != null)
                {
                    this.On("change", new JFunction(this.PostBackFunction));
                }
            }

            if (!string.IsNullOrEmpty(this.StoreID))
            {
                Store store = ControlUtils.FindControl <Store>(this, this.StoreID, true);
                if (store == null)
                {
                    throw new InvalidOperationException(string.Format("The Control '{0}' could not find the StoreID of '{1}'.", this.ID, this.StoreID));
                }

                if (this.SelectedItems.Count > 0)
                {
                    HandlerConfig options = new HandlerConfig();
                    options.Single = true;
                    string template = "{0}.store.on(\"{1}\",{2},{3},{4});";

                    string values  = this.SelectedItems.ValuesToJsonArray();
                    string indexes = this.SelectedItems.IndexesToJsonArray(true);


                    string suppressEvent = this.FireSelectOnLoad ? "false" : "true";
                    values  = values != "[]" ? string.Concat(".setValue(", values, ", true, ", suppressEvent, ");") : "";
                    indexes = indexes != "[]" ? string.Concat(".setValueByIndex(", indexes, ", true, ", suppressEvent, ");") : "";

                    this.AddScript(template,
                                   this.ClientID, "load",
                                   string.Concat("function(){", this.ClientID, values, indexes, this.ClientID, ".clearInvalid();}"),
                                   "this",
                                   options.ToJsonString()
                                   );
                }
            }
            else
            {
                if (this.SelectedItems.Count > 0)
                {
                    string values        = this.SelectedItems.ValuesToJsonArray();
                    string indexes       = this.SelectedItems.IndexesToJsonArray(true);
                    string suppressEvent = this.FireSelectOnLoad ? "false" : "true";

                    if (values != "[]")
                    {
                        this.AddScript(string.Concat(this.ClientID, ".setValue(", values, ", true, ", suppressEvent, ");"));
                    }

                    if (indexes != "[]")
                    {
                        this.AddScript(string.Concat(this.ClientID, ".setValue(", indexes, ", true, ", suppressEvent, ");"));
                    }
                }
            }
        }
Exemple #6
0
 public virtual void On(string eventName, JFunction handler, string scope, HandlerConfig options)
 {
     this.AddListener(eventName, handler.ToString(), scope, options);
 }
Exemple #7
0
        public virtual void AddListener(string eventName, string handler, string scope, HandlerConfig options)
        {
            string template = "{0}.on(\"{1}\",{2},{3},{4});";

            this.AddScript(template, this.ClientID, eventName, TokenUtils.ParseAndNormalize(handler, this), scope, options.ToJsonString());
        }