Example #1
0
        /// <summary>
        /// 获取隐藏选项卡的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetHideReference()
        {
            TabStrip tabStrip = Parent as TabStrip;

            if (tabStrip != null)
            {
                return(String.Format("{0}.hideTab('{1}');", tabStrip.ScriptID, ClientID));
            }
            return(String.Empty);
        }
Example #2
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            TabStrip tabStrip = Parent as TabStrip;

            if (EnableIFrame)
            {
                if (tabStrip.ActiveTabIndex >= 0 &&
                    tabStrip.ActiveTabIndex < tabStrip.Tabs.Count &&
                    this == tabStrip.Tabs[tabStrip.ActiveTabIndex])
                {
                    // 当前是激活选项卡
                }
                else
                {
                    // 对于非激活Tab,其中的Iframe需要延迟加载
                    OB.RemoveProperty("html");
                    OB.RemoveProperty("f_iframe_loaded");
                    OB.AddProperty("f_iframe_loaded", false);
                }
            }

            OB.AddProperty("f_type", "tab");

            //OB.AddProperty("__box_hidden_field_id", HiddenHiddenFieldID);

            if (EnableClose)
            {
                OB.AddProperty("closable", true);
            }

            //OB.RemoveProperty("hidden");
            //if (Hidden)
            //{
            //    AddStartupAbsoluteScript(GetHideReference());
            //}

            //OB.Listeners.AddProperty("beforeclose", JsHelper.GetFunction(GetHideReference() + "return false;", "cmp"), true);


            //string hiddenFieldsScript = String.Empty;
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(HiddenHiddenFieldID, Hidden.ToString().ToLower());
            ////hiddenFieldsScript += "\r\n";


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

            AddStartupScript(jsContent);
        }
Example #3
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            TabStrip tabStrip = Parent as TabStrip;

            if (EnableIFrame)
            {
                // 对于非激活Tab,其中的Iframe需要延迟加载
                if (this != tabStrip.Tabs[tabStrip.ActiveTabIndex])
                {
                    OB.RemoveProperty("html");
                    OB.RemoveProperty("x_iframe_loaded");
                    OB.AddProperty("x_iframe_loaded", false);
                }
            }

            OB.AddProperty("x_type", "tab");

            //OB.AddProperty("__box_hidden_field_id", HiddenHiddenFieldID);

            if (EnableClose)
            {
                OB.AddProperty("closable", true);
            }

            OB.RemoveProperty("hidden");
            if (Hidden)
            {
                //string hideScript = String.Format("{0}.hideTab(cmp);", tabStrip.ScriptID);
                //OB.Listeners.AddProperty("render", JsHelper.GetFunction(hideScript, "cmp"), true);
                AddStartupAbsoluteScript(GetHideReference());
            }

            //OB.Listeners.AddProperty("beforeclose", JsHelper.GetFunction(GetHideReference() + "return false;", "cmp"), true);


            //string hiddenFieldsScript = String.Empty;
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(HiddenHiddenFieldID, Hidden.ToString().ToLower());
            ////hiddenFieldsScript += "\r\n";


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

            AddStartupScript(jsContent);
        }
Example #4
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            if (EnableFrame)
            {
                OB.AddProperty("frame", true);
            }

            if (FooterBarAlign != FooterBarAlign.Right)
            {
                OB.AddProperty("buttonAlign", FooterBarAlignHelper.GetName(FooterBarAlign));
            }

            #region Items

            if (!RenderChildrenAsContent)
            {
                if (Items.Count > 0)
                {
                    JsArrayBuilder ab = new JsArrayBuilder();
                    foreach (ControlBase item in Items)
                    {
                        if (item.Visible)
                        {
                            ab.AddProperty(String.Format("{0}", item.XID), true);
                        }
                    }

                    OB.AddProperty("items", ab.ToString(), true);
                }
            }

            #endregion

            #region Toolbars

            foreach (Toolbar bar in Toolbars)
            {
                string toolbarID = String.Format("{0}", bar.XID);

                if (bar.Position == ToolbarPosition.Top)
                {
                    OB.AddProperty("tbar", toolbarID, true);
                }
                else if (bar.Position == ToolbarPosition.Bottom)
                {
                    OB.AddProperty("bbar", toolbarID, true);
                }
                else if (bar.Position == ToolbarPosition.Footer)
                {
                    OB.AddProperty("fbar", toolbarID, true);
                }
            }

            #endregion

            #region BodyStyle/ShowBorder

            string bodyStyleStr = BodyStyle;
            if (!bodyStyleStr.Contains("padding"))
            {
                if (!String.IsNullOrEmpty(BodyPadding))
                {
                    bodyStyleStr += String.Format("padding:{0};", BodyPadding);
                }
            }

            if (EnableBackgroundColor)
            {
                if (!bodyStyleStr.Contains("background-color"))
                {
                    string backgroundColorStyleStr = GlobalConfig.GetDefaultBackgroundColor();
                    if (!String.IsNullOrEmpty(backgroundColorStyleStr))
                    {
                        bodyStyleStr += String.Format("background-color:{0};", backgroundColorStyleStr);
                    }
                }
            }
            //else if (EnableLightBackgroundColor)
            //{
            //    if (!bodyStyleStr.Contains("background-color"))
            //    {
            //        string backgroundColorStyleStr = GlobalConfig.GetLightBackgroundColor(PageManager.Instance.Theme.ToString());
            //        bodyStyleStr += String.Format("background-color:{0};", backgroundColorStyleStr);
            //    }
            //}
            OB.AddProperty("bodyStyle", bodyStyleStr);

            OB.AddProperty("border", ShowBorder);


            #endregion


            #region Width/Height

            // 对于Panel,如果宽度/高度没有定义
            if (Width == Unit.Empty && AutoWidth)
            {
                OB.AddProperty("autoWidth", true);
            }

            if (Height == Unit.Empty && AutoHeight)
            {
                OB.AddProperty("autoHeight", true);
            }


            // 如果父控件是容器控件(不是ContentPanel),并且Layout != LayoutType.Container,
            // 则设置AutoWidth/AutoHeight都为false
            if (Parent is PanelBase)
            {
                PanelBase parent = Parent as PanelBase;
                if (!(parent is ContentPanel) && parent.Layout != Layout.Container)
                {
                    OB.RemoveProperty("autoHeight");
                    OB.RemoveProperty("autoWidth");
                }
            }



            if (AutoScroll)
            {
                OB.AddProperty("autoScroll", true);
            }


            #region old code
            //// 如果是 PageLayout 中的Panel,不能设置AutoWidth
            //if (Parent is PageLayout)
            //{
            //    // region
            //    if (Region != Region_Default) OB.AddProperty(OptionName.Region, RegionTypeName.GetName(Region.Value));
            //}
            //else
            //{
            //    // 对于Panel,如果宽度/高度没有定义,则使用自动宽度和高度
            //    if (Width == Unit.Empty)
            //    {
            //        OB.AddProperty(OptionName.AutoWidth, true);
            //    }

            //    if (Height == Unit.Empty)
            //    {
            //        OB.AddProperty(OptionName.AutoHeight, true);
            //    }

            //}

            //// 如果父控件是容器控件,并且Layout=Fit,则设置AutoWidth/AutoHeight都为false
            //if (Parent is PanelBase)
            //{
            //    PanelBase parentPanel = Parent as PanelBase;
            //    if (parentPanel.Layout == LayoutType.Fit
            //        || parentPanel.Layout == LayoutType.Anchor
            //        || parentPanel.Layout == LayoutType.Border)
            //    {
            //        OB.RemoveProperty(OptionName.AutoHeight);
            //        OB.RemoveProperty(OptionName.AutoWidth);
            //    }

            //}

            #endregion

            #endregion

            #region EnableIFrame

            if (EnableIFrame)
            {
                #region old code

                //string iframeJsContent = String.Empty;

                //string frameUrl = ResolveUrl(IFrameUrl);
                //JsObjectBuilder iframeBuilder = new JsObjectBuilder();
                //if (IFrameDelayLoad)
                //{
                //    iframeBuilder.AddProperty(OptionName.Src, "#");
                //}
                //else
                //{
                //    iframeBuilder.AddProperty(OptionName.Src, frameUrl);
                //}
                //iframeBuilder.AddProperty(OptionName.LoadMask, false);
                //iframeJsContent += String.Format("var {0}=new Ext.ux.ManagedIFrame('{0}',{1});", IFrameID, iframeBuilder.ToString());

                //if (IFrameDelayLoad)
                //{
                //    iframeJsContent += String.Format("{0}_url='{1}';", IFrameID, frameUrl);
                //}

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

                //AddStartupScript(this, iframeJsContent);

                #endregion

                // 注意:
                // 如下依附于现有对象的属性名称的定义规则:x_property1
                // 存储于当前对象实例中
                OB.AddProperty("x_iframe", true);
                OB.AddProperty("x_iframe_url", IFrameUrl);
                OB.AddProperty("x_iframe_name", IFrameName);

                // 如果定义了IFrameUrl,则直接写到页面中,否则先缓存到此对象中
                if (!String.IsNullOrEmpty(IFrameUrl))
                {
                    //_writeIframeToHtmlDocument = true;
                    OB.AddProperty("x_iframe_loaded", true);
                    // 直接添加iframe属性
                    OB.AddProperty("html", String.Format("<iframe src=\"{0}\" name=\"{1}\" frameborder=\"0\" style=\"height:100%;width:100%;overflow:auto;\"></iframe>", IFrameUrl, IFrameName));
                }
                else
                {
                    //_writeIframeToHtmlDocument = false;
                    OB.AddProperty("x_iframe_loaded", false);
                }

                #region old code

                //// If current panel is Tab, then process the IFrameDelayLoad property.
                //Tab tab = this as Tab;
                //if (tab != null && tab.IFrameDelayLoad)
                //{
                //    // 如果是Tab,并且此Tab不是激活的,则不添加iframe
                //    //_writeIframeToHtmlDocument = false;
                //    OB.AddProperty("box_property_iframe_loaded", false);
                //}
                //else
                //{
                //    // 如果定义了IFrameUrl,则直接写到页面中,否则先缓存到此对象中
                //    if (!String.IsNullOrEmpty(IFrameUrl))
                //    {
                //        //_writeIframeToHtmlDocument = true;
                //        OB.AddProperty("box_property_iframe_loaded", true);
                //        // 直接添加iframe属性
                //        OB.AddProperty("html", String.Format("<iframe src=\"{0}\" name=\"{1}\" frameborder=\"0\" style=\"height:100%;width:100%;overflow:auto;\"></iframe>", IFrameUrl, IFrameName));
                //    }
                //    else
                //    {
                //        //_writeIframeToHtmlDocument = false;
                //        OB.AddProperty("box_property_iframe_loaded", false);
                //    }
                //}

                #endregion
            }

            #endregion

            #region RoundBorder

            //if (RoundBorder) OB.AddProperty(OptionName.Frame, true);

            #endregion

            #region EnableLargeHeader

            if (EnableLargeHeader)
            {
                OB.AddProperty("cls", "box-panel-big-header");
            }

            #endregion

            #region remove fx

            // 关闭折叠时特效
            OB.AddProperty("animCollapse", false);

            #endregion

            #region ContentEl

            //string finallyScript = String.Empty;

            if (RenderChildrenAsContent)
            {
                OB.AddProperty("contentEl", ContentID);

                // 在页面元素渲染完成后,才显示容器控件的内容
                string renderScript = String.Format("Ext.get('{0}').show();", ContentID);
                OB.Listeners.AddProperty("render", "function(component){" + renderScript + "}", true);

                //string beforerenderScript = String.Format("Ext.get('{0}').setStyle('display','');", ChildrenContentID);
                //OB.Listeners.AddProperty("beforerender", "function(component){" + beforerenderScript + "}", true);


                // 这一段的逻辑(2008-9-1):
                // 如果是页面第一次加载 + 此Panel在Tab中 + 此Tab不是当前激活Tab + 此Tab的TabStrip启用了延迟加载
                // 那么在页面加载完毕后,把此Panel给隐藏掉,等此Panel渲染到页面中时再显示出来

                Tab tab = ControlUtil.FindParentControl(this, typeof(Tab)) as Tab;
                if (tab != null)
                {
                    TabStrip tabStrip = tab.Parent as TabStrip;
                    if (tabStrip.EnableDeferredRender && tabStrip.Tabs[tabStrip.ActiveTabIndex] != tab)
                    {
                        // 页面第一次加载时,在显示(控件的render事件)之前要先隐藏
                        AddStartupAbsoluteScript(String.Format("Ext.get('{0}').setStyle('display','none');", ContentID));
                    }
                }
            }

            #endregion
        }
Example #5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="parent">父控件实例</param>
 public TabCollection(TabStrip parent)
     : base(parent)
 {
 }