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

            #region Options

            JsObjectBuilder fieldDefaults = new JsObjectBuilder();
            if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                fieldDefaults.AddProperty("labelWidth", LabelWidth.Value);
            }
            if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                fieldDefaults.AddProperty("labelSeparator", LabelSeparator);
            }
            if (LabelAlign != ConfigPropertyValue.FORM_LABELALIGN_DEFAULT && LabelAlign != FineUI.LabelAlign.Undefined)
            {
                fieldDefaults.AddProperty("labelAlign", LabelAlignHelper.GetName(LabelAlign));
            }
            if (MessageTarget != ConfigPropertyValue.FORM_MESSAGETARGET_DEFAULT)
            {
                fieldDefaults.AddProperty("msgTarget", MessageTargetHelper.GetName(MessageTarget));
            }

            if (fieldDefaults.Count > 0)
            {
                OB.AddProperty("fieldDefaults", fieldDefaults);
            }


            #endregion
        }
示例#2
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("form");

            #region Options

            //JsObjectBuilder fieldDefaults = new JsObjectBuilder();
            if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                OB.AddProperty("labelWidth", LabelWidth.Value);
            }
            if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                OB.AddProperty("labelSeparator", LabelSeparator);
            }

            if (LabelAlign != LabelAlign.Left)
            {
                OB.AddProperty("labelAlign", LabelAlignHelper.GetName(LabelAlign));
            }

            //if (fieldDefaults.Count > 0)
            //{
            //    OB.AddProperty("fieldDefaults", fieldDefaults);
            //}

            //OB.AddProperty("msgTarget", "qtip");

            #region old code

            //// 如果存在Fields集合
            //if (Fields.Count > 0)
            //{
            //    JsArrayBuilder ab = new JsArrayBuilder();
            //    foreach (Field item in Fields)
            //    {
            //        ab.AddProperty(String.Format("{0}", item.ClientID), true);
            //    }
            //    OB.AddProperty(OptionName.Items, ab.ToString(), true);
            //}

            #endregion

            #endregion

            #region Anchor

            //JsObjectBuilder defaults = new JsObjectBuilder();

            //if (OffsetRight.Value != ConfigPropertyValue.FORM_OFFSETRIGHT_DEFAULT)
            //{
            //    defaults.AddProperty("anchor", -OffsetRight.Value);
            //}
            //else if (PageManager.Instance.FormOffsetRight.Value != ConfigPropertyValue.FORM_OFFSETRIGHT_DEFAULT)
            //{
            //    defaults.AddProperty("anchor", -PageManager.Instance.FormOffsetRight.Value);
            //}
            //else
            //{
            //    defaults.AddProperty("anchor", "auto");
            //}

            //OB.AddProperty("defaults", defaults);

            #endregion


            OB.Listeners.AddProperty("change", JsHelper.GetFunction("X.util.setPageStateChanged();"), true); //this.doLayout();

            string jsContent = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);


            #region old code

            //string doLayoutScript = String.Empty;

            //doLayoutScript += "\r\n";
            //if (Visible)
            //{
            //    doLayoutScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}.doLayout();}},box);", ClientJavascriptID);
            //}
            //AddAbsoluteStartupScript(doLayoutScript);

            #endregion
        }
示例#3
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            //ResourceManager.Instance.AddJavaScriptComponent("form");

            // 默认隐藏空白标签
            if (ShowEmptyLabel)
            {
                OB.AddProperty("hideEmptyLabel", false);
            }

            // 只有在表单中,有些属性才有效
            //if (ShowLabel)
            //{
            //    if (!String.IsNullOrEmpty(Label))
            //    {
            //        if (ShowRedStar)
            //        {
            //            OB.AddProperty("fieldLabel", Label + GetRedStarHtml());
            //        }
            //        else
            //        {
            //            OB.AddProperty("fieldLabel", Label);
            //        }
            //    }
            //}
            if (!ShowLabel)
            {
                OB.AddProperty("hideLabel", true);
            }


            // 即使ShowLabel=false,也要输出 Label 属性。可能会在标签验证失败对话框中用到[请为 用户名 提供有效值!]。
            if (!String.IsNullOrEmpty(Label))
            {
                if (ShowRedStar)
                {
                    OB.AddProperty("fieldLabel", Label + GetRedStarHtml());
                }
                else
                {
                    OB.AddProperty("fieldLabel", Label);
                }
            }


            if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                OB.AddProperty("labelSeparator", LabelSeparator);
            }

            if (LabelAlign != LabelAlign.Undefined)
            {
                OB.AddProperty("labelAlign", LabelAlignHelper.GetName(LabelAlign));
            }

            if (LabelWidth != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                OB.AddProperty("labelWidth", LabelWidth.Value);
            }

            //if (Width == Unit.Empty)
            ControlBase parentControl = GetParentControl();

            if (parentControl != null)
            {
                // 如果父控件布局是Anchor
                if (parentControl is FormRow ||
                    (parentControl is Container && (parentControl as Container).Layout == Layout.Anchor))
                {
                    // 如果定义了宽度,则不设置anchorValue
                    if (Width == Unit.Empty)
                    {
                        // 这个地方可能会覆盖 BoxComponent 中已经设置的 anchor 属性,不过没关系
                        OB.AddProperty("anchor", GetAnchorValue());
                    }
                }
            }


            // Every Field need a name property, which is used in form submit.
            OB.AddProperty("name", UniqueID);

            // Enabled has been processed in ControlBase.
            //OB.AddProperty(OptionName.Disabled, !Enabled);
            //if (AjaxPropertyChanged("Enabled", Enabled))
            //{
            //    AddAjaxPropertyChangedScript(String.Format("{0}.{1}();", XID, Enabled ? "enable" : "disable"));
            //    //AddAjaxPropertyChangedScript(String.Format("{0}.setDisabled({1});", ClientJavascriptID, !Enabled));
            //}

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

            if (Readonly)
            {
                OB.AddProperty("readOnly", true);
            }

            // We don't need to add this change event to all Field, only SimpleForm and Form has such event.
            // We have enableBubble for Ext.form.Field

            //// Fires just before the field blurs if the field value has changed.
            //string changeScript = "F.util.setPageStateChanged();";
            //OB.Listeners.AddProperty("change", JsHelper.GetFunction(changeScript), true);
        }
示例#4
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("form");

            #region Options

            //JsObjectBuilder fieldDefaults = new JsObjectBuilder();
            //if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            //{
            //    fieldDefaults.AddProperty("labelWidth", LabelWidth.Value);
            //}
            //if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            //{
            //    fieldDefaults.AddProperty("labelSeparator", LabelSeparator);
            //}

            //if (fieldDefaults.Count > 0)
            //{
            //    OB.AddProperty("fieldDefaults", fieldDefaults);
            //}

            if (LabelWidth.Value != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                OB.AddProperty("labelWidth", LabelWidth.Value);
            }
            if (LabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                OB.AddProperty("labelSeparator", LabelSeparator);
            }

            if (LabelAlign != LabelAlign.Left)
            {
                OB.AddProperty("labelAlign", LabelAlignHelper.GetName(LabelAlign));
            }

            #endregion

            #region ResolveRows

            // 包含行的列脚本
            string rowScriptStr = String.Empty;
            // 行的集合
            string rowItemScriptStr = String.Empty;

            // 如果存在Rows集合
            if (Rows.Count > 0)
            {
                // rowScriptStr
                // rowItemScriptStr: [X.__Panel1_UpdatePanelConnector1_Panel7_Form5_row0,X.__Panel1_UpdatePanelConnector1_Panel7_Form5_row2]
                ResolveRows(ref rowScriptStr, ref rowItemScriptStr);

                // 添加Items
                OB.RemoveProperty("items");
                OB.AddProperty("items", rowItemScriptStr, true);
            }

            //rowScriptStr += "\r\n";


            #endregion

            // This bug has been fixed in extjs v3.4.0.
            // Do layout when body size changed - I don't know why extjs do it automatically.
            // Why panel.layout.layout? Because Form outside layout doesn't has this function, why? I don't know now.
            //OB.Listeners.AddProperty("bodyresize", "function(panel){if(panel.layout.layout){panel.doLayout();}}", true);

            OB.Listeners.AddProperty("change", JsHelper.GetFunction("X.util.setPageStateChanged();"), true);


            string formPanelScript = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString());
            //AddStartupScript(this, rowScriptStr + formPanelScript);

            string jsContent = rowScriptStr + formPanelScript;
            AddStartupScript(jsContent);

            #region oldcode

            //string doLayoutScript = String.Empty;

            //doLayoutScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}.doLayout();}});", ClientJavascriptID);

            //AddPageFirstLoadAbsoluteScript(doLayoutScript);

            #endregion
        }