示例#1
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();



            #region Regions

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

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

            #endregion


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

            AddStartupScript(jsContent);
        }
示例#2
0
文件: Grid.cs 项目: g992com/esb
        private string GetGridColumnScript()
        {
            string selectModelID = Render_SelectModelID;
            string gridColumnID = Render_GridColumnModelID;
            // columns
            JsArrayBuilder columnsBuilder = new JsArrayBuilder();

            //string expanderScript = String.Empty;
            //if (!String.IsNullOrEmpty(RowExpander.DataFormatString))
            //{
            //    string tplStr = String.Format(RowExpander.DataFormatString.Replace("{", "{{{").Replace("}", "}}}"), RowExpander.DataFields);
            //    expanderScript = String.Format("var {0}=new Ext.ux.grid.RowExpander({{tpl:new Ext.Template({1})}});", Render_GridRowExpanderID, JsHelper.Enquote(tplStr));
            //    columnsBuilder.AddProperty(Render_GridRowExpanderID, true);
            //}

            // 如果启用行序号,则放在第一列
            if (EnableRowNumber)
            {
                columnsBuilder.AddProperty("new Ext.grid.RowNumberer()", true);
            }
            // 如果启用CheckBox,则放在第二列
            if (EnableCheckBoxSelect)
            {
                columnsBuilder.AddProperty(selectModelID, true);
            }

            string groupColumnScript = GetGroupColumnScript();

            string expanderScript = String.Empty;
            int columnIndex = 0;
            foreach (GridColumn column in AllColumns)
            {
                if (column is TemplateField && (column as TemplateField).RenderAsRowExpander)
                {
                    //string tplStr = String.Format(RowExpander.DataFormatString.Replace("{", "{{{").Replace("}", "}}}"), RowExpander.DataFields);
                    //expanderScript = String.Format("var {0}=new Ext.ux.grid.RowExpander({{tpl:new Ext.Template({1})}});", Render_GridRowExpanderID, JsHelper.Enquote(tplStr));
                    expanderScript = String.Format("var {0}=new Ext.ux.grid.RowExpander({{tpl:new Ext.Template(\"{{{1}}}\")}});", Render_GridRowExpanderID, Render_GridRowExpanderID);

                    columnsBuilder.AddProperty(Render_GridRowExpanderID, true);

                }
                else
                {
                    JsObjectBuilder columnBuilder = new JsObjectBuilder();
                    columnBuilder.AddProperty("header", String.IsNullOrEmpty(column.HeaderText) ? " " : column.HeaderText);
                    if (column.Hidden)
                    {
                        columnBuilder.AddProperty("hidden", true);
                    }

                    if (AllowSorting)
                    {
                        if (!String.IsNullOrEmpty(column.SortField))
                        {
                            //// 自定义JavaScript变量
                            columnBuilder.AddProperty("x_serverSortable", true);
                            //columnBuilder.AddProperty("sortable", true);
                        }
                    }

                    if (column.PersistState)
                    {
                        columnBuilder.AddProperty("x_persistState", true);
                        columnBuilder.AddProperty("x_persistStateType", "checkbox");
                    }

                    #region old code

                    // The following config will be in defaults
                    //columnBuilder.AddProperty(OptionName.Sortable, false);
                    //columnBuilder.AddProperty("menuDisabled", true);
                    //columnBuilder.AddProperty("hideable", false);

                    //// 如果启用服务器端排序,则禁用客户端排序
                    //if (EnableServerSort)
                    //{
                    //    columnBuilder.AddProperty(OptionName.Sortable, false);
                    //}
                    //else if (EnableClientSort)
                    //{
                    //    columnBuilder.AddProperty(OptionName.Sortable, true);
                    //}
                    //else
                    //{
                    //    columnBuilder.AddProperty(OptionName.Sortable, false);
                    //}
                    //    // 客户端排序,如果没有定义SortField,则不启用服务器端排序
                    //    if (!String.IsNullOrEmpty(column.SortField))
                    //    {
                    //        columnBuilder.AddProperty(OptionName.Sortable, true);
                    //    }
                    //    else
                    //    {
                    //        columnBuilder.AddProperty(OptionName.Sortable, false);
                    //    }
                    //}
                    //if (!String.IsNullOrEmpty(column.SortField))
                    //{
                    //    columnBuilder.AddProperty(OptionName.Sortable, true);
                    //}
                    //else
                    //{
                    //    columnBuilder.AddProperty(OptionName.Sortable, false);
                    //}

                    #endregion

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

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

                    if (column.Width != Unit.Empty)
                    {
                        columnBuilder.AddProperty("width", column.Width.Value);
                    }

                    columnsBuilder.AddProperty(columnBuilder);
                }

                columnIndex++;
            }

            // 为Grid添加plugin属性
            JsArrayBuilder pluginBuilder = new JsArrayBuilder();

            if (!String.IsNullOrEmpty(expanderScript))
            {
                pluginBuilder.AddProperty(Render_GridRowExpanderID, true);
            }

            if (!String.IsNullOrEmpty(groupColumnScript))
            {
                pluginBuilder.AddProperty(Render_GridGroupColumnID, true);
            }

            if (pluginBuilder.Count > 0)
            {
                OB.AddProperty("plugins", pluginBuilder.ToString(), true);
            }



            JsObjectBuilder defaultsBuilder = new JsObjectBuilder();
            // 这是Extjs默认的客户端排序
            //defaultsBuilder.AddProperty("sortable", false);
            //defaultsBuilder.AddProperty("menuDisabled", true);
            defaultsBuilder.AddProperty("width", 100);

            string columnModelScript = String.Format("var {0}=new Ext.grid.ColumnModel({{columns:{1},defaults:{2}}});", gridColumnID, columnsBuilder, defaultsBuilder);

            return expanderScript + groupColumnScript + columnModelScript;
        }
示例#3
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();



            #region Regions

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

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

            #endregion


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

            AddStartupScript(jsContent);

        }
示例#4
0
文件: Form.cs 项目: g992com/esb
        /// <summary>
        /// 处理列
        /// </summary>
        /// <returns></returns>
        private void ResolveRows(ref string rowScriptsStr, ref string rowIdsStr)
        {
            JsArrayBuilder rowIdsBuilder = new JsArrayBuilder();

            // 上一行的列数
            int lastRowColumnCount = 1;
            // 上一行的列数
            string lastRowColumnWidths = String.Empty;
            // 是否已经开始多列
            bool isMultiColumnStarted = false;
            // 多列的开始行的序号
            int multiColumnStartLineIndex = 0;

            for (int i = 0, rowCount = Rows.Count; i < rowCount; i++)
            {
                FormRow currentRow = Rows[i];
                int currentRowColumnCount = GetRowColumnCount(currentRow);
                string currentRowColumnWidths = currentRow.ColumnWidths;

                if (currentRowColumnCount == 0)
                {
                    // 如果当前行为空,则跳过此行
                    continue;
                }
                else if (currentRowColumnCount == 1)
                {
                    if (isMultiColumnStarted)
                    {
                        // 如果上一行是多列行,则添加本行之上的所有行
                        rowScriptsStr += AddColumnScript(rowIdsBuilder, multiColumnStartLineIndex, i - 1, lastRowColumnCount);
                        //rowScriptsStr += "\r\n";

                        // 开始重置记录本行为多列的开始
                        isMultiColumnStarted = false;
                        multiColumnStartLineIndex = 0;
                    }

                    // 如果当前行的列数为1,则直接添加Field元素
                    //AddItemScript(ab, currentRow.Fields[0].ClientID);
                    ControlBase component = GetRowColumnControl(currentRow, 0);
                    if (component != null)
                    {
                        rowIdsBuilder.AddProperty(String.Format("{0}", component.XID), true);
                    }
                }
                else
                {
                    // 如果本行是多列
                    if (!isMultiColumnStarted)
                    {
                        // 如果上一行还是单列的话,则开始多列
                        isMultiColumnStarted = true;
                        multiColumnStartLineIndex = i;
                    }
                    else
                    {
                        if (lastRowColumnCount == currentRowColumnCount && lastRowColumnWidths == currentRowColumnWidths)
                        {
                            // 如果上一行的列数和本行的列数相同(并且上一行每列的宽度和本行的每列宽度也一样),则继续下一行
                        }
                        else
                        {
                            // 如果上一行的列数和本行的列数不相同,则添加本行之上的所有行
                            rowScriptsStr += AddColumnScript(rowIdsBuilder, multiColumnStartLineIndex, i - 1, lastRowColumnCount);
                            //rowScriptsStr += "\r\n";

                            // 开始重新记录本行为多列的开始
                            isMultiColumnStarted = true;
                            multiColumnStartLineIndex = i;
                        }
                    }
                }


                lastRowColumnCount = currentRowColumnCount;
                lastRowColumnWidths = currentRowColumnWidths;
            }


            // 还要判断一下(如果最后一行是两列的情况)
            if (isMultiColumnStarted)
            {
                rowScriptsStr += AddColumnScript(rowIdsBuilder, multiColumnStartLineIndex, Rows.Count - 1, lastRowColumnCount);
                //rowScriptsStr += "\r\n";
            }

            rowIdsStr = rowIdsBuilder.ToString();
        }
示例#5
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region Reset ActiveIndex

            // ActiveIndex has been changed, reset Panes's Collapsed property.
            if (_activeIndex != -1)
            {
                foreach (AccordionPane pane in Panes)
                {
                    pane.Collapsed = true;
                }
                Panes[_activeIndex].Collapsed = false;
            }

            #endregion

            #region Panes

            if (Panes.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (AccordionPane item in Panes)
                {
                    if (item.Visible)
                    {
                        ab.AddProperty(String.Format("{0}", item.XID), true);
                    }
                }
                OB.AddProperty("items", ab.ToString(), true);
            }

            #endregion

            #region LayoutConfig

            JsObjectBuilder configBuilder = new JsObjectBuilder();
            configBuilder.AddProperty("animate", false);
            configBuilder.AddProperty("activeOnTop", EnableActiveOnTop);
            configBuilder.AddProperty("fill", EnableFill);
            configBuilder.AddProperty("hideCollapseTool", !ShowCollapseTool);
            //configBuilder.AddProperty(OptionName.TitleCollapse, true);
            //if (EnableLargeHeader)
            //{
            //    // 删除对CtCls的定义
            //    OB.RemoveProperty(OptionName.CtCls);
            //    configBuilder.AddProperty(OptionName.ExtraCls, "box-panel-big-header");
            //}

            OB.AddProperty("layoutConfig", configBuilder);

            #endregion



            //string activeScript = String.Empty;
            //activeScript += String.Format("var panel=Ext.getCmp(Ext.get(linkId).findParent('div.x-panel','{0}').id);panel.expand();", ClientID);
            //activeScript += String.Format("Ext.each(Ext.get('{0}').query('ul.box-accrodion-link-ul li'),function(ele){{Ext.get(ele).removeClass('box-accrodion-link-select');}});", ClientID);
            //activeScript += "Ext.get(Ext.get(linkId).findParent('li')).addClass('box-accrodion-link-select');";

            //string boxActiveFunction = String.Format("function(linkId){{{0}}}", activeScript);
            //OB.AddProperty("box_active", boxActiveFunction, true);



            string jsContent = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#6
0
文件: HtmlEditor.cs 项目: g992com/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            // Color需要菜单组件的支持
            if (EnableColors)
            {
                ResourceManager.Instance.AddJavaScriptComponent("menu");
            }

            if (!EnableAlignments) OB.AddProperty("enableAlignments", false);
            if (!EnableColors) OB.AddProperty("enableColors", false);
            if (!EnableFont) OB.AddProperty("enableFont", false);
            if (!EnableFontSize) OB.AddProperty("enableFontSize", false);
            if (!EnableFormat) OB.AddProperty("enableFormat", false);
            if (!EnableLinks) OB.AddProperty("enableLinks", false);
            if (!EnableLists) OB.AddProperty("enableLists", false);
            if (!EnableSourceEdit) OB.AddProperty("enableSourceEdit", false);

            #region Fonts

            string[] fonts = null;
            if (EnableChineseFont)
            {
                fonts = new string[] { "宋体", "黑体", "仿宋", "楷体", "隶书", "幼圆", "Arial", "Courier New", "Tahoma", "Times New Roman", "Verdana" };
            }
            else if (FontFamilies != null)
            {
                fonts = FontFamilies;
            }

            if (fonts != null && fonts.Length > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (string fontName in fonts)
                {
                    ab.AddProperty(fontName);
                }

                OB.AddProperty("fontFamilies", ab);
            }

            #endregion

            if (!String.IsNullOrEmpty(Text))
            {
                OB.AddProperty("value", Text);
            }

            string jsContent = String.Format("var {0}=new Ext.form.HtmlEditor({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#7
0
文件: Accordion.cs 项目: g992com/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region Reset ActiveIndex

            // ActiveIndex has been changed, reset Panes's Collapsed property.
            if (_activeIndex != -1)
            {
                foreach (AccordionPane pane in Panes)
                {
                    pane.Collapsed = true;
                }
                Panes[_activeIndex].Collapsed = false;
            }

            #endregion

            #region Panes

            if (Panes.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (AccordionPane item in Panes)
                {
                    if (item.Visible)
                    {
                        ab.AddProperty(String.Format("{0}", item.XID), true);
                    }
                }
                OB.AddProperty("items", ab.ToString(), true);
            }

            #endregion

            #region LayoutConfig

            JsObjectBuilder configBuilder = new JsObjectBuilder();
            configBuilder.AddProperty("animate", false);
            configBuilder.AddProperty("activeOnTop", EnableActiveOnTop);
            configBuilder.AddProperty("fill", EnableFill);
            configBuilder.AddProperty("hideCollapseTool", !ShowCollapseTool);
            //configBuilder.AddProperty(OptionName.TitleCollapse, true);
            //if (EnableLargeHeader)
            //{
            //    // 删除对CtCls的定义
            //    OB.RemoveProperty(OptionName.CtCls);
            //    configBuilder.AddProperty(OptionName.ExtraCls, "box-panel-big-header");
            //}

            OB.AddProperty("layoutConfig", configBuilder);

            #endregion



            //string activeScript = String.Empty;
            //activeScript += String.Format("var panel=Ext.getCmp(Ext.get(linkId).findParent('div.x-panel','{0}').id);panel.expand();", ClientID);
            //activeScript += String.Format("Ext.each(Ext.get('{0}').query('ul.box-accrodion-link-ul li'),function(ele){{Ext.get(ele).removeClass('box-accrodion-link-select');}});", ClientID);
            //activeScript += "Ext.get(Ext.get(linkId).findParent('li')).addClass('box-accrodion-link-select');";

            //string boxActiveFunction = String.Format("function(linkId){{{0}}}", activeScript);
            //OB.AddProperty("box_active", boxActiveFunction, true);



            string jsContent = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#8
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("tab");

            if (EnableTabCloseMenu)
            {
                ResourceManager.Instance.AddJavaScriptComponent("menu");
            }

            #region Tabs

            if (Tabs.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (Tab tab in Tabs)
                {
                    if (tab.Visible)
                    {
                        ab.AddProperty(String.Format("{0}", tab.XID), true);
                    }
                }
                OB.AddProperty("items", ab.ToString(), true);
            }

            #endregion

            #region options

            // 删除Layout配置参数
            OB.RemoveProperty("layout");

            //OB.AddProperty(OptionName.TabMargin, TabMargin.Value);
            OB.AddProperty("tabPosition", TabPositionHelper.GetName(TabPosition));
            //if (Plain) OB.AddProperty(OptionName.Plain, Plain);
            if (!EnableTitleBackgroundColor)
            {
                OB.AddProperty("plain", true);
            }


            // 去掉deferredRender=true,渲染速度会提高200ms左右
            // 每个Tab是否只在第一次访问时渲染,false表示全部渲染,否则没有访问的Tab的内容渲染的位置不正确。
            OB.AddProperty("deferredRender", EnableDeferredRender);

            //OB.AddProperty("bufferResize", true);

            // 在切换Tab时重新布局Tab的内容
            OB.AddProperty("layoutOnTabChange", true);

            OB.AddProperty("enableTabScroll", true);

            if (EnableTabCloseMenu)
            {
                OB.AddProperty("plugins", "new Ext.ux.TabCloseMenu()", true);
            }

            ////Note: By default, a tab's close tool destroys the child tab Component and all its descendants.
            //// This makes the child tab Component, and all its descendants unusable.
            //// To enable re-use of a tab, configure the TabPanel with autoDestroy: false.
            //OB.AddProperty("autoDestroy", false);

            #endregion

            #region ActiveTabIndex/IFrameDelayLoad

            OB.AddProperty("activeTab", ActiveTabIndex);

            //for (int i = 0; i < Tabs.Count; i++)
            //{
            //    Tab tab = Tabs[i];
            //    if (tab.EnableIFrame && i != ActiveTabIndex)
            //    {
            //        // 拥有IFrame的Tab如果不是激活Tab,则不设置Url,只有在激活时才设置Url
            //        tab.IFrameDelayLoad = true;
            //    }
            //    else
            //    {
            //        tab.IFrameDelayLoad = false;
            //    }
            //}

            #endregion

            #region Listeners

            #region old code

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

            // listeners
            //JsObjectBuilder listenersBuilder = new JsObjectBuilder();
            //listenersBuilder.AddProperty(OptionName.Tabchange, String.Format("function(tabPanel, activeTab){{Ext.get('{0}').dom.value=tabPanel.items.indexOf(activeTab);}}", ActiveTabHiddenField.ClientID), true);
            //OBuilder.AddProperty("listeners", listenersBuilder.ToString(), true);

            #endregion

            // 如果要激活的Tab含有IFrame,则需要加载IFrame
            // 改变Tab需要回发的脚本
            // Make sure X_AutoPostBackTabs property exist in X_STATE during page's first load.
            //string tabchangeScript2 = String.Format("if(tabPanel.x_autoPostBackTabsContains(tab.id)){{{0}}}", GetPostBackEventReference());

            string tabchangeScript = "X.wnd.updateIFrameNode(tab);";
            string postbackScript  = String.Empty;
            if (AutoPostBack)
            {
                tabchangeScript += "if(!tab.x_dynamic_added_tab){" + GetPostBackEventReference() + "}";
            }

            // 如果是动态添加的Tab,不做任何处理(在js/box/extender.js中)
            //string tabchangeScript = "X.wnd.updateIFrameNode(tab);if(!tab.x_dynamic_added_tab){" + postbackScript + "}";
            OB.Listeners.AddProperty("tabchange", JsHelper.GetFunction(tabchangeScript, "tabPanel", "tab"), true);

            #endregion

            #region old code

            //// 添加隐藏字段
            //string needPostBackTabIDsScript = GetNeedPostBackTabIDsScript();
            //hiddenFieldsScript += needPostBackTabIDsScript;

            //if (AjaxPropertyChanged("NeedPostBackTabIdsScript", needPostBackTabIDsScript))
            //{
            //    AddAjaxPropertyChangedScript(needPostBackTabIDsScript);
            //}


            //hiddenFieldsScript += GetSetHiddenFieldValueScript(ActiveTabHiddenFieldID, ActiveTabIndex.ToString().ToLower());

            #endregion

            #region old code

            //// An bug in IE.
            //string renderScript = "if(Ext.isIE){(function(){this.getActiveTab().removeClass('x-hide-display');}).defer(20,this);}";

            //OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderScript), true);

            #endregion

            string jsContent = String.Format("var {0}=new Ext.TabPanel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#9
0
文件: Menu.cs 项目: g992com/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

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

            #region Items

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

                    //if (item.Visible)
                    //{
                    //    ab.AddProperty(String.Format("{0}", item.ClientJavascriptID), true);
                    //}

                    //// 如果Item是否显示隐藏发生变化
                    //if (HashCodeChanged(item.ID + "", item.Visible))
                    //{
                    //    if (item.Visible)
                    //    {
                    //        item.AjaxForceCompleteUpdate = true;

                    //        AddAjaxPartialUpdateScript(String.Format("{0}.insert({1},X.{2});", ClientJavascriptID, ab.Count - 1, item.ClientJavascriptID));
                    //    }
                    //    else
                    //    {
                    //        AddAjaxPartialUpdateScript(String.Format("{0}.remove(X.{1});", ClientJavascriptID, item.ClientJavascriptID));
                    //    }
                    //}
                }

                if (ab.Count > 0)
                {
                    OB.AddProperty("items", ab.ToString(), true);
                }
            }

            #region old code

            //if (HashCodeChanged("Items", itemsString))
            //{
            //    StringBuilder ajaxUpdateBuilder = new StringBuilder();

            //    StringBuilder preUpdateBuilder = new StringBuilder();
            //    ajaxUpdateBuilder.AppendFormat("{0}.removeAll();", ClientJavascriptID);
            //    foreach (BaseMenuItem item in Items)
            //    {
            //        if (item.Visible)
            //        {
            //            if (item is MenuSeparator)
            //            {
            //                ajaxUpdateBuilder.AppendFormat("{0}.addSeparator();", ClientJavascriptID);
            //            }
            //            else if (item is MenuText)
            //            {
            //                ajaxUpdateBuilder.AppendFormat("{0}.addText({1});", ClientJavascriptID, JsHelper.Enquote((item as MenuText).Text));
            //            }
            //            else
            //            {
            //                preUpdateBuilder.AppendFormat("{0}_config=X.{0}.cloneConfig();", item.ClientJavascriptID);
            //                ajaxUpdateBuilder.AppendFormat("{1}=new Ext.menu.Item(X.{1}_config);X.{0}.addItem(X.{1});", ClientJavascriptID, item.ClientJavascriptID);
            //            }
            //        }
            //    }

            //    AddAjaxPartialUpdateScript(preUpdateBuilder.ToString() + ajaxUpdateBuilder.ToString());
            //} 
            #endregion

            #endregion


            if (Items.Count > 0)
            {
                string jsContent = String.Format("var {0}=new Ext.menu.Menu({1});", XID, OB.ToString());
                AddStartupScript(jsContent);
            }

        }
示例#10
0
文件: Button.cs 项目: g992com/esb
        /// <summary>
        /// 生成按钮客户端点击事件的脚本
        /// </summary>
        /// <param name="validateForms"></param>
        /// <param name="validateTarget"></param>
        /// <param name="enablePostBack"></param>
        /// <param name="postBackEventReference"></param>
        /// <param name="confirmText"></param>
        /// <param name="confirmTitle"></param>
        /// <param name="confirmIcon"></param>
        /// <param name="confirmTarget"></param>
        /// <param name="onClientClick"></param>
        /// <param name="disableControlJavascriptID"></param>
        /// <returns></returns>
        internal static string ResolveClientScript(string[] validateForms, Target validateTarget, bool validateMessageBox, bool enablePostBack, string postBackEventReference,
            string confirmText, string confirmTitle, MessageBoxIcon confirmIcon, Target confirmTarget, string onClientClick, string disableControlJavascriptID)
        {
            // 1. validateScript
            string validateScript = String.Empty;
            if (validateForms != null && validateForms.Length > 0)
            {
                #region old code

                //StringBuilder sb = new StringBuilder();
                //sb.Append("var forms=[];");
                //foreach (string formId in validateForms)
                //{
                //    Control control = ControlUtil.FindControl(formId);
                //    if (control != null && control is ControlBase)
                //    {
                //        sb.AppendFormat("forms.push(X.{0});", (control as ControlBase).ClientJavascriptID);
                //    }
                //}
                ////sb.Append("if(!box_validForms(forms,'表单不完整','请为 “{0}” 提供有效值!')){return false;}");
                //sb.AppendFormat("var validResult=X.util.validForms(forms);if(!validResult[0]){{{0}return false;}}",
                //    Alert.GetShowReference("请为 “'+validResult[1].fieldLabel+'” 提供有效值!", "表单不完整"));

                #endregion
                JsArrayBuilder array = new JsArrayBuilder();
                foreach (string formID in validateForms)
                {
                    Control control = ControlUtil.FindControl(formID);
                    if (control != null && control is ControlBase)
                    {
                        array.AddProperty((control as ControlBase).ClientID);
                    }
                }

                validateScript = String.Format("if(!X.util.validForms({0},'{1}',{2})){{return false;}}", array.ToString(), TargetHelper.GetName(validateTarget), validateMessageBox.ToString().ToLower());
            }

            // 2. 用户自定义脚本
            string clientClickScript = onClientClick;
            if (!String.IsNullOrEmpty(clientClickScript) && !clientClickScript.EndsWith(";"))
            {
                clientClickScript += ";";
            }


            // 3. 回发脚本
            string postBackScript = String.Empty;
            if (enablePostBack)
            {
                if (!String.IsNullOrEmpty(disableControlJavascriptID))
                {
                    postBackScript += String.Format("X.disable('{0}');", disableControlJavascriptID);
                    //postBackScript += String.Format("X.util.setHiddenFieldValue('{0}','{1}');", ResourceManager.DISABLED_CONTROL_BEFORE_POSTBACK, disableControlClientId);
                    //postBackScript += String.Format("X.util.setDisabledControlBeforePostBack('{0}');", disableControlJavascriptID);
                }
                postBackScript += postBackEventReference;
            }



            if (!String.IsNullOrEmpty(confirmText))
            {
                #region old code

                // 对confirm进行处理,对<script></script>包含的内容做js代码处理
                //string confirmText = ConfirmText.Replace("'", "\"");
                //if (confirmText.Contains("<script>"))
                //{
                //    confirmText = confirmText.Replace("<script>", "'+");
                //    confirmText = confirmText.Replace("</script>", "+'");
                //}
                //confirmText = String.Format("'{0}'", confirmText);

                //JsObjectBuilder ob = new JsObjectBuilder();
                //ob.AddProperty(OptionName.Title, String.Format("'{0}'", confirmTitle), true);
                //ob.AddProperty(OptionName.Msg, String.Format("'{0}'", JsHelper.GetStringWithJsBlock(confirmText)), true);
                //ob.AddProperty(OptionName.Buttons, "Ext.MessageBox.OKCANCEL", true);
                //ob.AddProperty(OptionName.Icon, String.Format("'{0}'", MessageBoxIconName.GetName(confirmIcon)), true);
                //ob.AddProperty(OptionName.Fn, String.Format("function(btn){{if(btn=='cancel'){{return false;}}else{{{0}}}}}", postBackScript), true);

                //postBackScript = String.Format("Ext.MessageBox.show({0});", ob.ToString()); 

                #endregion
                postBackScript = Confirm.GetShowReference(confirmText, confirmTitle, confirmIcon, postBackScript, "return false;", confirmTarget);
            }




            return validateScript + clientClickScript + postBackScript;
        }
示例#11
0
        /// <summary>
        /// 生成按钮客户端点击事件的脚本
        /// </summary>
        /// <param name="validateForms"></param>
        /// <param name="validateTarget"></param>
        /// <param name="enablePostBack"></param>
        /// <param name="postBackEventReference"></param>
        /// <param name="confirmText"></param>
        /// <param name="confirmTitle"></param>
        /// <param name="confirmIcon"></param>
        /// <param name="confirmTarget"></param>
        /// <param name="onClientClick"></param>
        /// <param name="disableControlJavascriptID"></param>
        /// <returns></returns>
        internal static string ResolveClientScript(string[] validateForms, Target validateTarget, bool validateMessageBox, bool enablePostBack, string postBackEventReference,
                                                   string confirmText, string confirmTitle, MessageBoxIcon confirmIcon, Target confirmTarget, string onClientClick, string disableControlJavascriptID)
        {
            // 1. validateScript
            string validateScript = String.Empty;

            if (validateForms != null && validateForms.Length > 0)
            {
                #region old code

                //StringBuilder sb = new StringBuilder();
                //sb.Append("var forms=[];");
                //foreach (string formId in validateForms)
                //{
                //    Control control = ControlUtil.FindControl(formId);
                //    if (control != null && control is ControlBase)
                //    {
                //        sb.AppendFormat("forms.push(X.{0});", (control as ControlBase).ClientJavascriptID);
                //    }
                //}
                ////sb.Append("if(!box_validForms(forms,'表单不完整','请为 “{0}” 提供有效值!')){return false;}");
                //sb.AppendFormat("var validResult=X.util.validForms(forms);if(!validResult[0]){{{0}return false;}}",
                //    Alert.GetShowReference("请为 “'+validResult[1].fieldLabel+'” 提供有效值!", "表单不完整"));

                #endregion
                JsArrayBuilder array = new JsArrayBuilder();
                foreach (string formID in validateForms)
                {
                    Control control = ControlUtil.FindControl(formID);
                    if (control != null && control is ControlBase)
                    {
                        array.AddProperty((control as ControlBase).ClientID);
                    }
                }

                validateScript = String.Format("if(!X.util.validForms({0},'{1}',{2})){{return false;}}", array.ToString(), TargetHelper.GetName(validateTarget), validateMessageBox.ToString().ToLower());
            }

            // 2. 用户自定义脚本
            string clientClickScript = onClientClick;
            if (!String.IsNullOrEmpty(clientClickScript) && !clientClickScript.EndsWith(";"))
            {
                clientClickScript += ";";
            }


            // 3. 回发脚本
            string postBackScript = String.Empty;
            if (enablePostBack)
            {
                if (!String.IsNullOrEmpty(disableControlJavascriptID))
                {
                    postBackScript += String.Format("X.disable('{0}');", disableControlJavascriptID);
                    //postBackScript += String.Format("X.util.setHiddenFieldValue('{0}','{1}');", ResourceManager.DISABLED_CONTROL_BEFORE_POSTBACK, disableControlClientId);
                    //postBackScript += String.Format("X.util.setDisabledControlBeforePostBack('{0}');", disableControlJavascriptID);
                }
                postBackScript += postBackEventReference;
            }



            if (!String.IsNullOrEmpty(confirmText))
            {
                #region old code

                // 对confirm进行处理,对<script></script>包含的内容做js代码处理
                //string confirmText = ConfirmText.Replace("'", "\"");
                //if (confirmText.Contains("<script>"))
                //{
                //    confirmText = confirmText.Replace("<script>", "'+");
                //    confirmText = confirmText.Replace("</script>", "+'");
                //}
                //confirmText = String.Format("'{0}'", confirmText);

                //JsObjectBuilder ob = new JsObjectBuilder();
                //ob.AddProperty(OptionName.Title, String.Format("'{0}'", confirmTitle), true);
                //ob.AddProperty(OptionName.Msg, String.Format("'{0}'", JsHelper.GetStringWithJsBlock(confirmText)), true);
                //ob.AddProperty(OptionName.Buttons, "Ext.MessageBox.OKCANCEL", true);
                //ob.AddProperty(OptionName.Icon, String.Format("'{0}'", MessageBoxIconName.GetName(confirmIcon)), true);
                //ob.AddProperty(OptionName.Fn, String.Format("function(btn){{if(btn=='cancel'){{return false;}}else{{{0}}}}}", postBackScript), true);

                //postBackScript = String.Format("Ext.MessageBox.show({0});", ob.ToString());

                #endregion
                postBackScript = Confirm.GetShowReference(confirmText, confirmTitle, confirmIcon, postBackScript, "return false;", confirmTarget);
            }



            return(validateScript + clientClickScript + postBackScript);
        }
示例#12
0
文件: PanelBase.cs 项目: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

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

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

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

            if (!String.IsNullOrEmpty(IconUrl))
            {
                // Window控件的特殊处理在Window控件中
                // 添加CSS样式
                string className = String.Format("extaspnet_{0}_panelbase_icon", XID);
                AddStartupCSS(className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(IconUrl)));

                OB.AddProperty("iconCls", className);

                //// 下面这种方式不行,这个样式是要添加到Head中的,而不是最外层的DIV
                //AddExtraStyle("background", StyleUtil.GetNoRepeatBackgroundStyleValue(ResolveUrl(IconUrl)));
            }

            #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
        }
示例#13
0
文件: Form.cs 项目: g992com/esb
 /// <summary>
 /// 添加Items变量
 /// </summary>
 /// <param name="ab"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 private void AddItemScript(JsArrayBuilder ab, string id)
 {
     ab.AddProperty(String.Format("{0}", id), true);
 }
示例#14
0
文件: Form.cs 项目: g992com/esb
        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="ab"></param>
        /// <param name="startLineIndex">开始行的索引(包含)</param>
        /// <param name="endLineIndex">结束行的索引(包含)</param>
        /// <param name="columnCount">行的列数</param>
        private string AddColumnScript(JsArrayBuilder rowIdsBuilder, int startLineIndex, int endLineIndex, int columnCount)
        {
            // 注意,注册脚本的控件应该是最后一个 Row
            // 假如有从上之下这些控件: Row1(Field1,Field2), Row2(Field3,Field4),Row3(Field5)
            // 则渲染时,JS脚本的执行顺序为:Field1,Field2,Row1,Field3,Field4,Row2,Field5,Row3
            // 所以,如果column Panel的脚本注册为控件 Row3,则能保证所有的子控件已经初始化
            // 需要注意的是:在此设置脚本内容到 Row3 控件
            // 现在已经不是这样的了!!!,Row不在是一个控件

            #region examples


            //            {
            //                    layout: 'column',
            //                    border:false,
            //                    items:[{
            //                        columnWidth: .5,
            //                        layout: 'form',
            //                        border:false,
            //                        items:[{
            //                            xtype:'combo',
            //                            store: nextStepStore,
            //                            displayField:'text',
            //                            valueField:'value',
            //                            typeAhead: true,
            //                            mode: 'local',
            //                            triggerAction: 'all',
            //                            value:'1',
            //                            emptyText:'请选择下一步',
            //                            selectOnFocus:true,
            //                            allowBlank:false,
            //                            fieldLabel: '下一步',
            //                            labelSeparator:'&nbsp;<span style="color:red;vertical-align:text-bottom;">*</span>',
            //                            name: 'nextStep',
            //                            anchor:'95%'
            //                        }]
            //                    },{
            //                        columnWidth: .5,
            //                        layout: 'form',
            //                        border:false,
            //                        items:[{
            //                            xtype:'combo',
            //                            store: executePersonStore,
            //                            displayField:'text',
            //                            valueField:'value',
            //                            typeAhead: true,
            //                            mode: 'local',
            //                            triggerAction: 'all',
            //                            value:'1',
            //                            emptyText:'请选择执行人',
            //                            selectOnFocus:true,
            //                            allowBlank:false,
            //                            fieldLabel: '执行人',
            //                            labelSeparator:'&nbsp;<span style="color:red;vertical-align:text-bottom;">*</span>',
            //                            name: 'executePerson',
            //                            anchor:'95%'
            //                        }]
            //                    }]
            //          }


            #endregion


            // 最后一行
            FormRow endLineRow = Rows[endLineIndex];
            string rowId = String.Format("{0}_row{1}", XID, endLineIndex);



            #region bodyStyleStr

            // 如果Form有背景色,这里也增加背景色
            string bodyStyleStr = String.Empty;
            if (EnableBackgroundColor)
            {
                bodyStyleStr = GlobalConfig.GetDefaultBackgroundColor();
            }
            //else if (EnableLightBackgroundColor)
            //{
            //    bodyStyleStr = GlobalConfig.GetLightBackgroundColor(PageManager.Instance.Theme.ToString());
            //}

            if (!String.IsNullOrEmpty(bodyStyleStr))
            {
                bodyStyleStr = String.Format("background-color:{0};", bodyStyleStr);
            }
            #endregion


            string defaultColumnWidthStr = (1.0 / columnCount).ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
            string[] columnWidths = ResolveColumnWidths(columnCount, Rows[startLineIndex].ColumnWidths, defaultColumnWidthStr);

            // row_column
            JsArrayBuilder rowColumnScriptsBuilder = new JsArrayBuilder();
            for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
            {
                #region 计算每一列的值

                // 循环每一列
                JsArrayBuilder fieldsAB = new JsArrayBuilder();
                for (int rowIndex = startLineIndex; rowIndex <= endLineIndex; rowIndex++)
                {
                    FormRow currentRow = Rows[rowIndex];

                    if (columnIndex <= GetRowColumnCount(currentRow) - 1)
                    {
                        ControlBase component = GetRowColumnControl(currentRow, columnIndex);
                        if (component != null)
                        {
                            fieldsAB.AddProperty(String.Format("{0}", component.XID), true);
                        }
                    }
                }

                // 当前列的创建JS
                JsObjectBuilder columnOB = new JsObjectBuilder();
                string columnWidth = columnWidths[columnIndex];
                if (Convert.ToDouble(columnWidth) <= 1.0)
                {
                    columnOB.AddProperty("columnWidth", columnWidths[columnIndex], true);
                }
                else
                {
                    columnOB.AddProperty("width", columnWidths[columnIndex], true);
                }

                columnOB.AddProperty("layout", "form");
                columnOB.AddProperty("border", false);
                columnOB.AddProperty("bodyStyle", bodyStyleStr);
                columnOB.AddProperty("labelWidth", LabelWidth.Value);
                columnOB.AddProperty("id", rowId + "_column" + columnIndex.ToString());

                // 有可能为空
                if (fieldsAB.Count > 0)
                {
                    columnOB.AddProperty("items", fieldsAB.ToString(), true);
                }


                rowColumnScriptsBuilder.AddProperty(columnOB.ToString(), true);

                // 现在采取的是安全的ajax,不会出现下面的情况
                //// 所有Layout=form的地方必须用Ext.FormPanel,否则删除时不会把FieldLabek删除掉
                //rowColumnScriptsBuilder.AddProperty(String.Format("new Ext.FormPanel({0})", columnOB.ToString()), true);

                #endregion
            }

            // 外面的JS(X.__Panel1_UpdatePanelConnector1_Panel7_Form5_row0)
            JsObjectBuilder rowBuilder = new JsObjectBuilder();
            rowBuilder.AddProperty("layout", "column");
            rowBuilder.AddProperty("border", false);
            rowBuilder.AddProperty("bodyStyle", bodyStyleStr);

            // 有可能为空
            if (rowColumnScriptsBuilder.Count > 0)
            {
                rowBuilder.AddProperty("items", rowColumnScriptsBuilder.ToString(), true);
            }


            // 把当前节点添加到结果集合中
            rowIdsBuilder.AddProperty(String.Format("{0}", rowId), true);
            rowBuilder.AddProperty("id", rowId);

            // 注意要注册 最后 一个 Row的脚本
            return String.Format("var {0}=new Ext.Panel({1});", rowId, rowBuilder.ToString());
        }
示例#15
0
文件: Grid.cs 项目: g992com/esb
        private string GetGroupColumnScript()
        {
            if (Columns.Count > 0)
            {
                return String.Empty;
            }

            List<List<GridGroupColumn>> resolvedGroups = new List<List<GridGroupColumn>>();
            ResolveGroupColumns(GroupColumns, 0, resolvedGroups);

            JsArrayBuilder groupHeaderBuilder = new JsArrayBuilder();

            foreach (List<GridGroupColumn> groups in resolvedGroups)
            {
                JsArrayBuilder groupsBuilder = new JsArrayBuilder();
                foreach (GridGroupColumn group in groups)
                {
                    JsObjectBuilder groupBuilder = new JsObjectBuilder();
                    groupBuilder.AddProperty("header", group.HeaderText);
                    if (group.TextAlign != TextAlign.Left)
                    {
                        groupBuilder.AddProperty("align", TextAlignName.GetName(group.TextAlign));
                    }

                    int groupColumnCount = 0;
                    ResolveColumnCount(group, ref groupColumnCount);
                    groupBuilder.AddProperty("colspan", groupColumnCount);

                    groupsBuilder.AddProperty(groupBuilder);
                }

                groupHeaderBuilder.AddProperty(groupsBuilder);
            }

            return String.Format("var {0}=new Ext.ux.grid.ColumnHeaderGroup({{rows:{1}}});", Render_GridGroupColumnID, groupHeaderBuilder.ToString());

        }
示例#16
0
文件: Grid.cs 项目: g992com/esb
        private string GetGridStore()
        {
            JsObjectBuilder storeBuilder = new JsObjectBuilder();

            // store - fields
            JsArrayBuilder fieldsBuidler = new JsArrayBuilder();
            foreach (GridColumn column in AllColumns)
            {
                #region old code
                //JsObjectBuilder fieldBuilder = new JsObjectBuilder();
                //fieldBuilder.AddProperty("name", column.ColumnID);
                ////fieldBuilder.AddProperty(OptionName.Mapping, columnIndex);
                ////fieldBuilder.AddProperty(OptionName.Type, column.GetFieldType());

                //fieldsBuidler.AddProperty(fieldBuilder);
                //columnIndex++; 
                #endregion
                if (column is TemplateField && (column as TemplateField).RenderAsRowExpander)
                {
                    fieldsBuidler.AddProperty(Render_GridRowExpanderID);
                }
                else
                {
                    fieldsBuidler.AddProperty(column.ColumnID);
                }
            }

            //// 如果Grid启用RowExpander,需要附加额外的数据
            //if (!String.IsNullOrEmpty(RowExpander.DataFormatString))
            //{
            //    foreach (string field in RowExpander.DataFields)
            //    {
            //        fieldsBuidler.AddProperty(field);
            //    }
            //}

            storeBuilder.AddProperty("fields", fieldsBuidler, true);

            return String.Format("var {0}=new Ext.data.ArrayStore({1});", Render_GridStoreID, storeBuilder.ToString());

            #region old code

            //storeBuilder.AddProperty("remoteSort", true);
            //storeBuilder.AddProperty("proxy", String.Format("new Ext.ux.AspNetProxy('{0}')", ClientID), true);

            //storeBuilder.AddProperty("autoLoad", "{params:{start:0,limit:" + PageSize + "}}", true);
            //storeBuilder.AddProperty("data", GetDatas());

            //if (AllowSorting)
            //{
            //    // Default sort info
            //    if (SortColumnIndex >= 0 && SortColumnIndex < Columns.Count)
            //    {
            //        JsObjectBuilder sortInfoBuilder = new JsObjectBuilder();
            //        sortInfoBuilder.AddProperty("field", Columns[SortColumnIndex].ColumnID);
            //        sortInfoBuilder.AddProperty("direction", SortDirection);

            //        storeBuilder.AddProperty("sortInfo", sortInfoBuilder);
            //    }
            //}


            //return String.Format("var {0}=new Ext.data.ArrayStore({1});", Render_GridStoreID, storeBuilder.ToString());


            //#region store - data
            ////string dataArrayString = GetDataArrayString(startEndRowIndex[0], startEndRowIndex[1]);



            //int[] startEndRowIndex = GetStartEndRowIndex();
            //// 计算完要渲染到前台的数据的条数,就要检查当前选中的项是不是有越界的
            //ResolveSelectedRowIndexArray(startEndRowIndex[1] - startEndRowIndex[0]);

            //#endregion 
            #endregion

            #region old code

            //JsArrayBuilder rowIndexBuilder = new JsArrayBuilder();

            //if (SelectedRowIndexArray != null && SelectedRowIndexArray.Length > 0)
            //{
            //    foreach (int rowIndex in SelectedRowIndexArray)
            //    {
            //        rowIndexBuilder.AddProperty(rowIndex);
            //    }
            //}
            //string selectRowScript = String.Format("{0}.selectRows({1});", Render_SelectModelID, rowIndexBuilder);
            //// 选中哪些行,这个必须要defer(100),否则选不中,晕(10ms就不行)
            //selectRowScript = String.Format("(function(){{{0}}}).defer(100);", selectRowScript);

            //storeBuilder.AddProperty("listeners", String.Format("{{load:{0}}}", String.Format("function(){{{0}}}", selectRowScript)), true);

            #endregion

            #region old code

            // TODO
            //string selectedRowIndexArrayString = StringUtil.GetStringFromIntArray(SelectedRowIndexArray);
            //// ExtAspNetAjax回发并且Columns发生变化,需要重新
            //if (_ExtAspNetAjaxColumnsChanged)
            //{
            //    string reconfigScript = String.Empty;
            //    reconfigScript += gridStoreScript;
            //    reconfigScript += String.Format("{0}.reconfigure({1},{2});", XID, Render_GridStoreID, Render_GridColumnModelID);
            //    reconfigScript += String.Format("{0}.load();", Render_GridStoreID);
            //    // 重新加载数据后要更新input选中哪些项(因为可能选中项也会变化)
            //    reconfigScript += GetSetHiddenFieldValueScript(SelectedRowIndexArrayHiddenFieldID, selectedRowIndexArrayString);

            //    AddAjaxPropertyChangedScript(reconfigScript);
            //}
            //else
            //{
            //    bool reloadData = false;
            //    string updateSelectRowScript = selectRowScript + GetSetHiddenFieldValueScript(SelectedRowIndexArrayHiddenFieldID, selectedRowIndexArrayString);
            //    if (AjaxPropertyChanged("DataArrayString", dataArrayString))
            //    {
            //        string reloadDataScript = String.Format("{0}.loadData({1});", Render_GridStoreID, dataArrayString);
            //        // 虽然有可能“不需要修改隐藏字段的值,因为SelectedRowIndexArray其实并没有变化,只是重新加载数据(reloadData)导致选中项丢失了”
            //        // 但是我们还是修改了input的值,这没有什么影响
            //        reloadDataScript += updateSelectRowScript;

            //        AddAjaxPropertyChangedScript(reloadDataScript);

            //        reloadData = true;
            //    }

            //    // 不管SelectedRowIndexArray==null或者是不为空,都要做这一步
            //    // 在Ajax回发中,selectedRowIndexArrayString改变了,并且没有重新加载数据
            //    if (AjaxPropertyChanged("SelectedRowIndexArrayString", selectedRowIndexArrayString) && !reloadData)
            //    {
            //        AddAjaxPropertyChangedScript(updateSelectRowScript);
            //    }

            //} 
            #endregion

            #region old code

            //gridStoreScript += "\r\n";
            //if (EnableClientPaging)
            //{

            //    // 进行分页时,改变隐藏input的值,以在回发时保持状态
            //    // 同时注意:客户端分页时,清空选中的值
            //    JsObjectBuilder listenersBuilder = new JsObjectBuilder();
            //    listenersBuilder.AddProperty(OptionName.Load, String.Format("function(store,records,options){{Ext.get('{0}').dom.value=options.params.start;Ext.get('{1}').dom.value='';}}", EnableClientPagingStartRowIndexID, SelectedRowsHiddenFieldID), true);
            //    storeBuilder.AddProperty("listeners", listenersBuilder);
            //}

            // 每次都是加载全部
            //loadStoreScript = String.Format("{0}.load({1});", gridStoreId, "{params:{start:0,limit:" + (endRowIndex - startRowIndex + 1) + "}}");


            //// load store
            ////string loadStoreScript = String.Empty;
            //if (EnableClientPaging)
            //{
            //    loadStoreScript = String.Format("{0}.load({1});", gridStoreId, "{params:{start:" + EnableClientPagingStartRowIndex + ",limit:" + PageSize + "}}");
            //}
            //else
            //{
            //    loadStoreScript = String.Format("{0}.load({1});", gridStoreId, "{params:{start:0,limit:" + Rows.Count + "}}");
            //}

            //gridStoreScript += loadStoreScript; 
            #endregion
        }
示例#17
0
        /// <summary>
        /// 处理列
        /// </summary>
        /// <returns></returns>
        private void ResolveRows(ref string rowScriptsStr, ref string rowIdsStr)
        {
            JsArrayBuilder rowIdsBuilder = new JsArrayBuilder();

            // 上一行的列数
            int lastRowColumnCount = 1;
            // 上一行的列数
            string lastRowColumnWidths = String.Empty;
            // 是否已经开始多列
            bool isMultiColumnStarted = false;
            // 多列的开始行的序号
            int multiColumnStartLineIndex = 0;

            for (int i = 0, rowCount = Rows.Count; i < rowCount; i++)
            {
                FormRow currentRow             = Rows[i];
                int     currentRowColumnCount  = GetRowColumnCount(currentRow);
                string  currentRowColumnWidths = currentRow.ColumnWidths;

                if (currentRowColumnCount == 0)
                {
                    // 如果当前行为空,则跳过此行
                    continue;
                }
                else if (currentRowColumnCount == 1)
                {
                    if (isMultiColumnStarted)
                    {
                        // 如果上一行是多列行,则添加本行之上的所有行
                        rowScriptsStr += AddColumnScript(rowIdsBuilder, multiColumnStartLineIndex, i - 1, lastRowColumnCount);
                        //rowScriptsStr += "\r\n";

                        // 开始重置记录本行为多列的开始
                        isMultiColumnStarted      = false;
                        multiColumnStartLineIndex = 0;
                    }

                    // 如果当前行的列数为1,则直接添加Field元素
                    //AddItemScript(ab, currentRow.Fields[0].ClientID);
                    ControlBase component = GetRowColumnControl(currentRow, 0);
                    if (component != null)
                    {
                        rowIdsBuilder.AddProperty(String.Format("{0}", component.XID), true);
                    }
                }
                else
                {
                    // 如果本行是多列
                    if (!isMultiColumnStarted)
                    {
                        // 如果上一行还是单列的话,则开始多列
                        isMultiColumnStarted      = true;
                        multiColumnStartLineIndex = i;
                    }
                    else
                    {
                        if (lastRowColumnCount == currentRowColumnCount && lastRowColumnWidths == currentRowColumnWidths)
                        {
                            // 如果上一行的列数和本行的列数相同(并且上一行每列的宽度和本行的每列宽度也一样),则继续下一行
                        }
                        else
                        {
                            // 如果上一行的列数和本行的列数不相同,则添加本行之上的所有行
                            rowScriptsStr += AddColumnScript(rowIdsBuilder, multiColumnStartLineIndex, i - 1, lastRowColumnCount);
                            //rowScriptsStr += "\r\n";

                            // 开始重新记录本行为多列的开始
                            isMultiColumnStarted      = true;
                            multiColumnStartLineIndex = i;
                        }
                    }
                }


                lastRowColumnCount  = currentRowColumnCount;
                lastRowColumnWidths = currentRowColumnWidths;
            }


            // 还要判断一下(如果最后一行是两列的情况)
            if (isMultiColumnStarted)
            {
                rowScriptsStr += AddColumnScript(rowIdsBuilder, multiColumnStartLineIndex, Rows.Count - 1, lastRowColumnCount);
                //rowScriptsStr += "\r\n";
            }

            rowIdsStr = rowIdsBuilder.ToString();
        }
示例#18
0
文件: PanelBase.cs 项目: g992com/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

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

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

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

            if (!String.IsNullOrEmpty(IconUrl))
            {
                // Window控件的特殊处理在Window控件中
                // 添加CSS样式
                string className = String.Format("extaspnet_{0}_panelbase_icon", XID);
                AddStartupCSS(className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(IconUrl)));

                OB.AddProperty("iconCls", className);

                //// 下面这种方式不行,这个样式是要添加到Head中的,而不是最外层的DIV
                //AddExtraStyle("background", StyleUtil.GetNoRepeatBackgroundStyleValue(ResolveUrl(IconUrl)));
            }

            #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
        }
示例#19
0
        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="ab"></param>
        /// <param name="startLineIndex">开始行的索引(包含)</param>
        /// <param name="endLineIndex">结束行的索引(包含)</param>
        /// <param name="columnCount">行的列数</param>
        private string AddColumnScript(JsArrayBuilder rowIdsBuilder, int startLineIndex, int endLineIndex, int columnCount)
        {
            // 注意,注册脚本的控件应该是最后一个 Row
            // 假如有从上之下这些控件: Row1(Field1,Field2), Row2(Field3,Field4),Row3(Field5)
            // 则渲染时,JS脚本的执行顺序为:Field1,Field2,Row1,Field3,Field4,Row2,Field5,Row3
            // 所以,如果column Panel的脚本注册为控件 Row3,则能保证所有的子控件已经初始化
            // 需要注意的是:在此设置脚本内容到 Row3 控件
            // 现在已经不是这样的了!!!,Row不在是一个控件

            #region examples


            //            {
            //                    layout: 'column',
            //                    border:false,
            //                    items:[{
            //                        columnWidth: .5,
            //                        layout: 'form',
            //                        border:false,
            //                        items:[{
            //                            xtype:'combo',
            //                            store: nextStepStore,
            //                            displayField:'text',
            //                            valueField:'value',
            //                            typeAhead: true,
            //                            mode: 'local',
            //                            triggerAction: 'all',
            //                            value:'1',
            //                            emptyText:'请选择下一步',
            //                            selectOnFocus:true,
            //                            allowBlank:false,
            //                            fieldLabel: '下一步',
            //                            labelSeparator:'&nbsp;<span style="color:red;vertical-align:text-bottom;">*</span>',
            //                            name: 'nextStep',
            //                            anchor:'95%'
            //                        }]
            //                    },{
            //                        columnWidth: .5,
            //                        layout: 'form',
            //                        border:false,
            //                        items:[{
            //                            xtype:'combo',
            //                            store: executePersonStore,
            //                            displayField:'text',
            //                            valueField:'value',
            //                            typeAhead: true,
            //                            mode: 'local',
            //                            triggerAction: 'all',
            //                            value:'1',
            //                            emptyText:'请选择执行人',
            //                            selectOnFocus:true,
            //                            allowBlank:false,
            //                            fieldLabel: '执行人',
            //                            labelSeparator:'&nbsp;<span style="color:red;vertical-align:text-bottom;">*</span>',
            //                            name: 'executePerson',
            //                            anchor:'95%'
            //                        }]
            //                    }]
            //          }


            #endregion


            // 最后一行
            FormRow endLineRow = Rows[endLineIndex];
            string  rowId      = String.Format("{0}_row{1}", XID, endLineIndex);



            #region bodyStyleStr

            // 如果Form有背景色,这里也增加背景色
            string bodyStyleStr = String.Empty;
            if (EnableBackgroundColor)
            {
                bodyStyleStr = GlobalConfig.GetDefaultBackgroundColor();
            }
            //else if (EnableLightBackgroundColor)
            //{
            //    bodyStyleStr = GlobalConfig.GetLightBackgroundColor(PageManager.Instance.Theme.ToString());
            //}

            if (!String.IsNullOrEmpty(bodyStyleStr))
            {
                bodyStyleStr = String.Format("background-color:{0};", bodyStyleStr);
            }
            #endregion


            string   defaultColumnWidthStr = (1.0 / columnCount).ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
            string[] columnWidths          = ResolveColumnWidths(columnCount, Rows[startLineIndex].ColumnWidths, defaultColumnWidthStr);

            // row_column
            JsArrayBuilder rowColumnScriptsBuilder = new JsArrayBuilder();
            for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
            {
                #region 计算每一列的值

                // 循环每一列
                JsArrayBuilder fieldsAB = new JsArrayBuilder();
                for (int rowIndex = startLineIndex; rowIndex <= endLineIndex; rowIndex++)
                {
                    FormRow currentRow = Rows[rowIndex];

                    if (columnIndex <= GetRowColumnCount(currentRow) - 1)
                    {
                        ControlBase component = GetRowColumnControl(currentRow, columnIndex);
                        if (component != null)
                        {
                            fieldsAB.AddProperty(String.Format("{0}", component.XID), true);
                        }
                    }
                }

                // 当前列的创建JS
                JsObjectBuilder columnOB    = new JsObjectBuilder();
                string          columnWidth = columnWidths[columnIndex];
                if (Convert.ToDouble(columnWidth) <= 1.0)
                {
                    columnOB.AddProperty("columnWidth", columnWidths[columnIndex], true);
                }
                else
                {
                    columnOB.AddProperty("width", columnWidths[columnIndex], true);
                }

                columnOB.AddProperty("layout", "form");
                columnOB.AddProperty("border", false);
                columnOB.AddProperty("bodyStyle", bodyStyleStr);
                columnOB.AddProperty("labelWidth", LabelWidth.Value);
                columnOB.AddProperty("id", rowId + "_column" + columnIndex.ToString());

                // 有可能为空
                if (fieldsAB.Count > 0)
                {
                    columnOB.AddProperty("items", fieldsAB.ToString(), true);
                }


                rowColumnScriptsBuilder.AddProperty(columnOB.ToString(), true);

                // 现在采取的是安全的ajax,不会出现下面的情况
                //// 所有Layout=form的地方必须用Ext.FormPanel,否则删除时不会把FieldLabek删除掉
                //rowColumnScriptsBuilder.AddProperty(String.Format("new Ext.FormPanel({0})", columnOB.ToString()), true);

                #endregion
            }

            // 外面的JS(X.__Panel1_UpdatePanelConnector1_Panel7_Form5_row0)
            JsObjectBuilder rowBuilder = new JsObjectBuilder();
            rowBuilder.AddProperty("layout", "column");
            rowBuilder.AddProperty("border", false);
            rowBuilder.AddProperty("bodyStyle", bodyStyleStr);

            // 有可能为空
            if (rowColumnScriptsBuilder.Count > 0)
            {
                rowBuilder.AddProperty("items", rowColumnScriptsBuilder.ToString(), true);
            }


            // 把当前节点添加到结果集合中
            rowIdsBuilder.AddProperty(String.Format("{0}", rowId), true);
            rowBuilder.AddProperty("id", rowId);

            // 注意要注册 最后 一个 Row的脚本
            return(String.Format("var {0}=new Ext.Panel({1});", rowId, rowBuilder.ToString()));
        }
示例#20
0
文件: Menu.cs 项目: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

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

            #region Items

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

                    //if (item.Visible)
                    //{
                    //    ab.AddProperty(String.Format("{0}", item.ClientJavascriptID), true);
                    //}

                    //// 如果Item是否显示隐藏发生变化
                    //if (HashCodeChanged(item.ID + "", item.Visible))
                    //{
                    //    if (item.Visible)
                    //    {
                    //        item.AjaxForceCompleteUpdate = true;

                    //        AddAjaxPartialUpdateScript(String.Format("{0}.insert({1},X.{2});", ClientJavascriptID, ab.Count - 1, item.ClientJavascriptID));
                    //    }
                    //    else
                    //    {
                    //        AddAjaxPartialUpdateScript(String.Format("{0}.remove(X.{1});", ClientJavascriptID, item.ClientJavascriptID));
                    //    }
                    //}
                }

                if (ab.Count > 0)
                {
                    OB.AddProperty("items", ab.ToString(), true);
                }
            }

            #region old code

            //if (HashCodeChanged("Items", itemsString))
            //{
            //    StringBuilder ajaxUpdateBuilder = new StringBuilder();

            //    StringBuilder preUpdateBuilder = new StringBuilder();
            //    ajaxUpdateBuilder.AppendFormat("{0}.removeAll();", ClientJavascriptID);
            //    foreach (BaseMenuItem item in Items)
            //    {
            //        if (item.Visible)
            //        {
            //            if (item is MenuSeparator)
            //            {
            //                ajaxUpdateBuilder.AppendFormat("{0}.addSeparator();", ClientJavascriptID);
            //            }
            //            else if (item is MenuText)
            //            {
            //                ajaxUpdateBuilder.AppendFormat("{0}.addText({1});", ClientJavascriptID, JsHelper.Enquote((item as MenuText).Text));
            //            }
            //            else
            //            {
            //                preUpdateBuilder.AppendFormat("{0}_config=X.{0}.cloneConfig();", item.ClientJavascriptID);
            //                ajaxUpdateBuilder.AppendFormat("{1}=new Ext.menu.Item(X.{1}_config);X.{0}.addItem(X.{1});", ClientJavascriptID, item.ClientJavascriptID);
            //            }
            //        }
            //    }

            //    AddAjaxPartialUpdateScript(preUpdateBuilder.ToString() + ajaxUpdateBuilder.ToString());
            //}
            #endregion

            #endregion


            if (Items.Count > 0)
            {
                string jsContent = String.Format("var {0}=new Ext.menu.Menu({1});", XID, OB.ToString());
                AddStartupScript(jsContent);
            }
        }
示例#21
0
 /// <summary>
 /// 添加Items变量
 /// </summary>
 /// <param name="ab"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 private void AddItemScript(JsArrayBuilder ab, string id)
 {
     ab.AddProperty(String.Format("{0}", id), true);
 }
示例#22
0
文件: TabStrip.cs 项目: g992com/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("tab");

            if (EnableTabCloseMenu)
            {
                ResourceManager.Instance.AddJavaScriptComponent("menu");
            }

            #region Tabs

            if (Tabs.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (Tab tab in Tabs)
                {
                    if (tab.Visible)
                    {
                        ab.AddProperty(String.Format("{0}", tab.XID), true);
                    }
                }
                OB.AddProperty("items", ab.ToString(), true);
            }

            #endregion

            #region options

            // 删除Layout配置参数
            OB.RemoveProperty("layout");

            //OB.AddProperty(OptionName.TabMargin, TabMargin.Value);
            OB.AddProperty("tabPosition", TabPositionHelper.GetName(TabPosition));
            //if (Plain) OB.AddProperty(OptionName.Plain, Plain);
            if (!EnableTitleBackgroundColor)
            {
                OB.AddProperty("plain", true);
            }


            // 去掉deferredRender=true,渲染速度会提高200ms左右
            // 每个Tab是否只在第一次访问时渲染,false表示全部渲染,否则没有访问的Tab的内容渲染的位置不正确。
            OB.AddProperty("deferredRender", EnableDeferredRender);

            //OB.AddProperty("bufferResize", true);

            // 在切换Tab时重新布局Tab的内容
            OB.AddProperty("layoutOnTabChange", true);

            OB.AddProperty("enableTabScroll", true);

            if (EnableTabCloseMenu)
            {
                OB.AddProperty("plugins", "new Ext.ux.TabCloseMenu()", true);
            }

            ////Note: By default, a tab's close tool destroys the child tab Component and all its descendants. 
            //// This makes the child tab Component, and all its descendants unusable. 
            //// To enable re-use of a tab, configure the TabPanel with autoDestroy: false. 
            //OB.AddProperty("autoDestroy", false);

            #endregion

            #region ActiveTabIndex/IFrameDelayLoad

            OB.AddProperty("activeTab", ActiveTabIndex);

            //for (int i = 0; i < Tabs.Count; i++)
            //{
            //    Tab tab = Tabs[i];
            //    if (tab.EnableIFrame && i != ActiveTabIndex)
            //    {
            //        // 拥有IFrame的Tab如果不是激活Tab,则不设置Url,只有在激活时才设置Url
            //        tab.IFrameDelayLoad = true;
            //    }
            //    else
            //    {
            //        tab.IFrameDelayLoad = false;
            //    }
            //}

            #endregion

            #region Listeners

            #region old code

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

            // listeners
            //JsObjectBuilder listenersBuilder = new JsObjectBuilder();
            //listenersBuilder.AddProperty(OptionName.Tabchange, String.Format("function(tabPanel, activeTab){{Ext.get('{0}').dom.value=tabPanel.items.indexOf(activeTab);}}", ActiveTabHiddenField.ClientID), true);
            //OBuilder.AddProperty("listeners", listenersBuilder.ToString(), true);

            #endregion

            // 如果要激活的Tab含有IFrame,则需要加载IFrame
            // 改变Tab需要回发的脚本
            // Make sure X_AutoPostBackTabs property exist in X_STATE during page's first load.
            //string tabchangeScript2 = String.Format("if(tabPanel.x_autoPostBackTabsContains(tab.id)){{{0}}}", GetPostBackEventReference());

            string tabchangeScript = "X.wnd.updateIFrameNode(tab);";
            string postbackScript = String.Empty;
            if (AutoPostBack)
            {
                tabchangeScript += "if(!tab.x_dynamic_added_tab){" + GetPostBackEventReference() + "}";
            }

            // 如果是动态添加的Tab,不做任何处理(在js/box/extender.js中)
            //string tabchangeScript = "X.wnd.updateIFrameNode(tab);if(!tab.x_dynamic_added_tab){" + postbackScript + "}";
            OB.Listeners.AddProperty("tabchange", JsHelper.GetFunction(tabchangeScript, "tabPanel", "tab"), true);

            #endregion

            #region old code

            //// 添加隐藏字段
            //string needPostBackTabIDsScript = GetNeedPostBackTabIDsScript();
            //hiddenFieldsScript += needPostBackTabIDsScript;

            //if (AjaxPropertyChanged("NeedPostBackTabIdsScript", needPostBackTabIDsScript))
            //{
            //    AddAjaxPropertyChangedScript(needPostBackTabIDsScript);
            //}


            //hiddenFieldsScript += GetSetHiddenFieldValueScript(ActiveTabHiddenFieldID, ActiveTabIndex.ToString().ToLower());

            #endregion

            #region old code

            //// An bug in IE.
            //string renderScript = "if(Ext.isIE){(function(){this.getActiveTab().removeClass('x-hide-display');}).defer(20,this);}";

            //OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderScript), true);

            #endregion

            string jsContent = String.Format("var {0}=new Ext.TabPanel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#23
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            // Color需要菜单组件的支持
            if (EnableColors)
            {
                ResourceManager.Instance.AddJavaScriptComponent("menu");
            }

            if (!EnableAlignments)
            {
                OB.AddProperty("enableAlignments", false);
            }
            if (!EnableColors)
            {
                OB.AddProperty("enableColors", false);
            }
            if (!EnableFont)
            {
                OB.AddProperty("enableFont", false);
            }
            if (!EnableFontSize)
            {
                OB.AddProperty("enableFontSize", false);
            }
            if (!EnableFormat)
            {
                OB.AddProperty("enableFormat", false);
            }
            if (!EnableLinks)
            {
                OB.AddProperty("enableLinks", false);
            }
            if (!EnableLists)
            {
                OB.AddProperty("enableLists", false);
            }
            if (!EnableSourceEdit)
            {
                OB.AddProperty("enableSourceEdit", false);
            }

            #region Fonts

            string[] fonts = null;
            if (EnableChineseFont)
            {
                fonts = new string[] { "宋体", "黑体", "仿宋", "楷体", "隶书", "幼圆", "Arial", "Courier New", "Tahoma", "Times New Roman", "Verdana" };
            }
            else if (FontFamilies != null)
            {
                fonts = FontFamilies;
            }

            if (fonts != null && fonts.Length > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (string fontName in fonts)
                {
                    ab.AddProperty(fontName);
                }

                OB.AddProperty("fontFamilies", ab);
            }

            #endregion

            if (!String.IsNullOrEmpty(Text))
            {
                OB.AddProperty("value", Text);
            }

            string jsContent = String.Format("var {0}=new Ext.form.HtmlEditor({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#24
0
文件: Toolbar.cs 项目: xlfj5211/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

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

            #region Items

            // 重新设置Items
            if (Controls.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (Control item in Controls)
                {
                    if (item is ControlBase && item.Visible)
                    {
                        #region old code

                        //// 如果是分隔符
                        //if (item is ToolbarSeparator)
                        //{
                        //    ab.AddProperty("'-'", true);
                        //}
                        //else if (item is ToolbarText)
                        //{
                        //    ab.AddProperty(String.Format("'{0}'", (item as ToolbarText).Text), true);
                        //}
                        //if (item is ToolbarFill)
                        //{
                        //    ab.AddProperty("'->'", true);
                        //}
                        //else
                        //{
                        //ab.AddProperty(String.Format("{0}", (item as ControlBase).ClientJavascriptID), true);
                        //}

                        #endregion

                        ab.AddProperty(String.Format("{0}", (item as ControlBase).XID), true);
                    }
                }

                if (ab.Count > 0)
                {
                    OB.AddProperty("items", ab.ToString(), true);
                }
            }


            #endregion

            //#region IsPageMenu

            //// 如果是页面的菜单,使用特殊的样式
            //if (IsPageMenu)
            //{
            //    OB.AddProperty(OptionName.Cls, "box-toolbar-pagemenu");

            //    // 这个样式在CSS中设置会被覆盖
            //    string style = CssStyle + "border:0px;";
            //    OB.AddProperty(OptionName.Style, style);

            //}

            //#endregion

            string jsContent = String.Format("var {0}=new Ext.Toolbar({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
示例#25
0
文件: Toolbar.cs 项目: g992com/esb
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

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

            #region Items

            // 重新设置Items
            if (Controls.Count > 0)
            {
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (Control item in Controls)
                {
                    if (item is ControlBase && item.Visible)
                    {
                        #region old code

                        //// 如果是分隔符
                        //if (item is ToolbarSeparator)
                        //{
                        //    ab.AddProperty("'-'", true);
                        //}
                        //else if (item is ToolbarText)
                        //{
                        //    ab.AddProperty(String.Format("'{0}'", (item as ToolbarText).Text), true);
                        //}
                        //if (item is ToolbarFill)
                        //{
                        //    ab.AddProperty("'->'", true);
                        //}
                        //else
                        //{
                        //ab.AddProperty(String.Format("{0}", (item as ControlBase).ClientJavascriptID), true);
                        //} 

                        #endregion

                        ab.AddProperty(String.Format("{0}", (item as ControlBase).XID), true);
                    }
                }

                if (ab.Count > 0)
                {
                    OB.AddProperty("items", ab.ToString(), true);
                }
            }


            #endregion

            //#region IsPageMenu

            //// 如果是页面的菜单,使用特殊的样式
            //if (IsPageMenu)
            //{
            //    OB.AddProperty(OptionName.Cls, "box-toolbar-pagemenu");

            //    // 这个样式在CSS中设置会被覆盖
            //    string style = CssStyle + "border:0px;";
            //    OB.AddProperty(OptionName.Style, style);

            //} 

            //#endregion

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

        }