Beispiel #1
0
        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
        }
Beispiel #2
0
        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);
            //}

            #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
        }