コード例 #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()
                               );
            }
        }
コード例 #2
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, ");"));
                    }
                }
            }
        }
コード例 #3
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());
        }