Ejemplo n.º 1
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //ResourceManager.Instance.AddJavaScriptComponent("button");
            //if (Menu.Items.Count > 0)
            //{
            //    ResourceManager.Instance.AddJavaScriptComponent("menu");
            //}

            #region Properties
            if (TabIndex != null)
            {
                OB.AddProperty("tabIndex", TabIndex);
            }

            if (!String.IsNullOrEmpty(ToolTip))
            {
                OB.AddProperty("tooltip", ToolTip);
                OB.AddProperty("tooltipType", ToolTipTypeName.GetName(ToolTipType));
            }

            OB.AddProperty("text", Text);

            if (EnablePress)
            {
                OB.AddProperty("enableToggle", EnablePress);
                OB.AddProperty("pressed", Pressed);

                //hiddenFieldsScript += GetSetHiddenFieldValueScript(PressedHiddenFieldID, Pressed.ToString().ToLower());
                //string toggleScript = String.Format("function(btn,pressed){{X.util.setHiddenFieldValue('{0}',pressed);}}", PressedHiddenFieldID);
                //OB.Listeners.AddProperty(OptionName.Toggle, toggleScript, true);
            }

            if (Type != ButtonType.Button)
            {
                OB.AddProperty("type", ButtonTypeName.GetName(Type));
            }

            if (Size != ButtonSize.Small)
            {
                OB.AddProperty("scale", ButtonSizeName.GetName(Size));
            }

            #endregion

            #region Icon IconUrl

            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                // 不需要先删除原来的属性,因为在AddProperty内部已经有这个逻辑了
                OB.AddProperty("cls", CssClass + " x-btn-text-icon");
                OB.AddProperty("icon", resolvedIconUrl);

                if (IconAlign != IconAlign.Left)
                {
                    OB.AddProperty("iconAlign", IconAlignHelper.GetName(IconAlign));
                }
            }

            #endregion

            #region Click

            string clickScript = GetClickScript();
            if (!String.IsNullOrEmpty(clickScript))
            {
                OB.AddProperty("handler", JsHelper.GetFunction(clickScript), true);
            }

            #endregion

            #region oldcode

            //string clickScriptFunction = GetClickScriptFunction();
            //if (AjaxPropertyChanged("ClickScriptFunction", clickScriptFunction))
            //{
            //    string ajaxClickFunction = String.Empty;
            //    //ajaxClickFunction += String.Format("{0}.purgeListeners('click');", ClientJavascriptID);
            //    ajaxClickFunction += String.Format("{0}.un('click', X.{0}.initialConfig.listeners.click);", XID);
            //    ajaxClickFunction += String.Format("{0}.on('click',{1});", XID, clickScriptFunction);

            //    AddAjaxPropertyChangedScript(ajaxClickFunction);
            //}

            //OB.Listeners.AddProperty(OptionName.Click, String.Format("{0}_click", ClientJavascriptID), true);


            //OB.AddProperty(OptionName.Handler, "function(){alert('sss');}", true);



            //string style = String.Empty;

            //if (CssStyle == "" || !CssStyle.ToLower().Contains("display"))
            //{
            //    style += CssStyle + "display:inline;";
            //}

            //OB.RemoveProperty(OptionName.Style);
            //OB.AddProperty(OptionName.Style, style);

            //AddExtraStyle("display", "inline");

            #endregion

            #region Menu

            if (_menu != null && Menu.Items.Count > 0)
            {
                OB.AddProperty("menu", String.Format("{0}", Menu.XID), true);
            }


            #endregion

            string createScript = String.Format("var {0}=new Ext.Button({1});", XID, OB.ToString());
            AddStartupScript(createScript);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            if (this is TemplateField && (this as TemplateField).RenderAsRowExpander)
            {
                // 行扩展列需要特殊处理
            }
            else
            {
                //JsObjectBuilder columnBuilder = new JsObjectBuilder();

                // 列的禁用会反映到每个单元格上,而不是在列头
                OB.RemoveProperty("disabled");

                if (this is RowNumberField)
                {
                    OB.AddProperty("xtype", "rownumberer");
                }

                OB.AddProperty("text", GetHeaderValue());

                if (!String.IsNullOrEmpty(HeaderToolTip))
                {
                    OB.AddProperty("tooltip", HeaderToolTip);
                    OB.AddProperty("tooltipType", ToolTipTypeName.GetName(HeaderToolTipType));
                }

                if (Hidden)
                {
                    OB.AddProperty("hidden", true);
                }

                if (!String.IsNullOrEmpty(InnerCls))
                {
                    OB.AddProperty("innerCls", InnerCls);
                }

                if (Grid.AllowSorting)
                {
                    if (String.IsNullOrEmpty(SortField))
                    {
                        OB.AddProperty("sortable", false);
                    }
                    else
                    {
                        OB.AddProperty("sortable", true);
                    }
                }
                else
                {
                    OB.AddProperty("sortable", false);
                }


                // 允许列锁定
                if (Grid.AllowColumnLocking)
                {
                    if (EnableLock)
                    {
                        OB.AddProperty("lockable", true);
                    }
                    else
                    {
                        OB.AddProperty("lockable", false);
                    }

                    if (Locked)
                    {
                        OB.AddProperty("lockable", true);
                        OB.AddProperty("locked", true);
                    }
                }


                if (PersistState)
                {
                    OB.AddProperty("f_persistState", true);
                    OB.AddProperty("f_persistStateType", "checkbox");
                }



                //If not specified, the column's index is used as an index into the Record's data Array.
                OB.AddProperty("dataIndex", ColumnID);
                OB.AddProperty("id", ColumnID);

                // 服务器端使用的ColumnIndex
                OB.AddProperty("f_columnIndex", ColumnIndex);


                /*
                 * if (TextAlign != TextAlign.Left)
                 * {
                 *  OB.AddProperty("align", TextAlignName.GetName(TextAlign));
                 * }
                 */
                if (TextAlign != null)
                {
                    // 行序号列默认靠右显示;其他靠左显示;所以只要定义了 TextAlign,就输出
                    OB.AddProperty("align", TextAlignName.GetName(TextAlign.Value));
                }

                if (Width != Unit.Empty)
                {
                    OB.AddProperty("width", Width.Value);
                }
                else if (BoxFlex != 0)
                {
                    OB.AddProperty("flex", BoxFlex);
                }

                if (MinWidth != Unit.Empty)
                {
                    OB.AddProperty("minWidth", MinWidth.Value);
                }

                if (ExpandUnusedSpace)
                {
                    OB.AddProperty("flex", 1);
                }

                if (Grid.EnableHeaderMenu)
                {
                    if (EnableHeaderMenu)
                    {
                        OB.AddProperty("menuDisabled", false);
                    }
                    else
                    {
                        OB.AddProperty("menuDisabled", true);
                    }
                }
                else
                {
                    OB.AddProperty("menuDisabled", true);
                }

                if (EnableColumnHide)
                {
                    OB.AddProperty("hideable", true);
                }
                else
                {
                    OB.AddProperty("hideable", false);
                }

                // mod by wz
                //if (Grid.EnableSummary)
                //{
                //    if (this is RowNumberField)
                //    {
                //        // 序号列 没有合计
                //    }
                //    else
                //    {
                //        OB.AddProperty("summaryType", String.Format("F.util.summaryType('{0}')", Grid.ClientID), true);
                //    }
                //}

                if (this is BoundField)
                {
                    if (DataType == GridColumnDataType.Default)
                    {
                        // do nothing
                    }
                    else
                    {
                        OB.AddProperty("xtype", GridColumnDataTypeHelper.GetName(DataType));
                    }
                }

                if (Grid.EnableSummary)
                {
                    if (this is RowNumberField)
                    {
                        // 序号列 没有合计
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(SummaryType) && string.IsNullOrEmpty(SummaryRenderer))
                        {
                            OB.AddProperty("summaryType", String.Format("F.util.summaryType('{0}')", Grid.ClientID), true);
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(SummaryType))
                            {
                                OB.AddProperty("summaryType", SummaryType);
                            }
                            if (!string.IsNullOrEmpty(SummaryRenderer))
                            {
                                OB.AddProperty("summaryRenderer", SummaryRenderer, true);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            if (this is TemplateField && (this as TemplateField).RenderAsRowExpander)
            {
                // 行扩展列需要特殊处理
            }
            else
            {
                //JsObjectBuilder columnBuilder = new JsObjectBuilder();

                // 列的禁用会反映到每个单元格上,而不是在列头
                OB.RemoveProperty("disabled");

                if (this is RowNumberField)
                {
                    OB.AddProperty("xtype", "rownumberer");
                }

                OB.AddProperty("text", GetHeaderValue());

                if (!String.IsNullOrEmpty(HeaderToolTip))
                {
                    OB.AddProperty("tooltip", HeaderToolTip);
                    OB.AddProperty("tooltipType", ToolTipTypeName.GetName(HeaderToolTipType));
                }

                if (Hidden)
                {
                    OB.AddProperty("hidden", true);
                }

                if (!String.IsNullOrEmpty(InnerCls))
                {
                    OB.AddProperty("innerCls", InnerCls);
                }

                if (Grid.AllowSorting)
                {
                    if (String.IsNullOrEmpty(SortField))
                    {
                        OB.AddProperty("sortable", false);
                    }
                    else
                    {
                        OB.AddProperty("sortable", true);
                    }
                }
                else
                {
                    OB.AddProperty("sortable", false);
                }


                if (PersistState)
                {
                    OB.AddProperty("f_persistState", true);
                    OB.AddProperty("f_persistStateType", "checkbox");
                }



                //If not specified, the column's index is used as an index into the Record's data Array.
                OB.AddProperty("dataIndex", ColumnID);
                OB.AddProperty("id", ColumnID);

                if (TextAlign != TextAlign.Left)
                {
                    OB.AddProperty("align", TextAlignName.GetName(TextAlign));
                }

                if (Width != Unit.Empty)
                {
                    OB.AddProperty("width", Width.Value);
                }
                else if (BoxFlex != 0)
                {
                    OB.AddProperty("flex", BoxFlex);
                }

                if (ExpandUnusedSpace)
                {
                    OB.AddProperty("flex", 1);
                }

                if (Grid.EnableHeaderMenu)
                {
                    if (EnableHeaderMenu)
                    {
                        OB.AddProperty("menuDisabled", false);
                    }
                    else
                    {
                        OB.AddProperty("menuDisabled", true);
                    }
                }
                else
                {
                    OB.AddProperty("menuDisabled", true);
                }

                if (EnableColumnHide)
                {
                    OB.AddProperty("hideable", true);
                }
                else
                {
                    OB.AddProperty("hideable", false);
                }


                if (Grid.EnableSummary)
                {
                    if (this is RowNumberField)
                    {
                        // 序号列 没有合计
                    }
                    else
                    {
                        OB.AddProperty("summaryType", String.Format("F.util.summaryType('{0}')", Grid.ClientID), true);
                    }
                }
            }
        }