Beispiel #1
0
        /// <summary>
        /// 获取显示确认对话框的客户端脚本
        /// </summary>
        /// <param name="message">对话框消息</param>
        /// <param name="title">对话框标题</param>
        /// <param name="icon">对话框图标</param>
        /// <param name="okScriptstring">点击确定按钮执行的客户端脚本</param>
        /// <param name="cancelScript">点击取消按钮执行的客户端脚本</param>
        /// <param name="target">弹出对话框的目标页面</param>
        /// <returns>客户端脚本</returns>
        public static string GetShowReference(string message, string title, MessageBoxIcon icon, string okScriptstring, string cancelScript, Target target)
        {
            //string msgBoxScript = "var msgBox=Ext.MessageBox;";
            //msgBoxScript += "if(parent!=window){msgBox=parent.window.Ext.MessageBox;}";
            if (String.IsNullOrEmpty(title))
            {
                title = "X.util.confirmTitle";
            }
            else
            {
                title = JsHelper.GetJsString(title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }
            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");


            JsObjectBuilder ob = new JsObjectBuilder();

            ob.AddProperty("title", title, true);
            ob.AddProperty("msg", JsHelper.GetJsStringWithScriptTag(message), true);
            ob.AddProperty("buttons", "Ext.MessageBox.OKCANCEL", true);
            ob.AddProperty("icon", String.Format("{0}", MessageBoxIconHelper.GetName(icon)), true);
            ob.AddProperty("fn", String.Format("function(btn){{if(btn=='cancel'){{{0}}}else{{{1}}}}}", cancelScript, okScriptstring), true);

            string targetName = "window";

            if (target != Target.Self)
            {
                targetName = TargetHelper.GetScriptName(target);
            }
            return(String.Format("{0}.Ext.MessageBox.show({1});", targetName, ob.ToString()));
        }
Beispiel #2
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            // 行扩展列需要特殊处理
            if (this is TemplateField && (this 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}}}\")}});", Grid.Render_GridRowExpanderID, Grid.Render_GridRowExpanderID);


                string jsContent = String.Format("var {0}=new Ext.ux.grid.RowExpander({{tpl:new Ext.Template(\"{{{1}}}\")}});", XID, ColumnID);
                AddStartupScript(jsContent);
            }
            else
            {
                JsObjectBuilder columnBuilder = new JsObjectBuilder();

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

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

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

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



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

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

                if (Width != Unit.Empty)
                {
                    OB.AddProperty("width", Width.Value);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region Options

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

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


            #endregion
        }
Beispiel #4
0
        //public override string GetFieldType()
        //{
        //    return "string";
        //}

        #endregion

        #region OnFirstPreRender

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

            if (this is TemplateField && (this as TemplateField).RenderAsRowExpander)
            {
                JsObjectBuilder rowExpanderBuilder = new JsObjectBuilder();
                rowExpanderBuilder.AddProperty("rowBodyTpl", String.Format("Ext.create('Ext.XTemplate','{{{0}}}')", ColumnID), true);
                rowExpanderBuilder.AddProperty("pluginId", String.Format("{0}_rowexpander", Grid.ClientID));

                if (!ExpandOnDoubleClick)
                {
                    rowExpanderBuilder.AddProperty("expandOnDblClick", false);
                }

                if (!ExpandOnEnter)
                {
                    rowExpanderBuilder.AddProperty("expandOnEnter", false);
                }

                if (ExpandToSelectRow)
                {
                    rowExpanderBuilder.AddProperty("selectRowOnExpand", true);
                }


                string jsContent = String.Format("var {0}=Ext.create('Ext.grid.plugin.RowExpander',{1});", XID, rowExpanderBuilder);
                AddGridColumnScript(jsContent);
            }
            else
            {
                string jsContent = String.Format("var {0}={1};", XID, OB.ToString());
                AddGridColumnScript(jsContent);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取添加选项卡的脚本
        /// </summary>
        /// <param name="tabID">选项卡ID</param>
        /// <param name="iframeUrl">IFrame地址</param>
        /// <param name="tabTitle">选项卡标题</param>
        /// <param name="iconUrl">选项卡图标</param>
        /// <param name="enableClose">是否可以关闭</param>
        /// <returns>客户端脚本</returns>
        public string GetAddTabReference(string tabID, string iframeUrl, string tabTitle, string iconUrl, bool enableClose)
        {
            if (!String.IsNullOrEmpty(iframeUrl))
            {
                iframeUrl = ResolveIFrameUrl(iframeUrl);
            }

            JsObjectBuilder options = new JsObjectBuilder();

            options.AddProperty("id", tabID);
            options.AddProperty("url", iframeUrl);
            options.AddProperty("title", tabTitle);
            options.AddProperty("closable", enableClose);

            string iconScript = String.Empty;

            if (!String.IsNullOrEmpty(iconUrl))
            {
                string className = String.Format("icon_{0}", System.Guid.NewGuid().ToString("N"));
                iconScript = String.Format("F.addCSS('{0}','{1}');", className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(iconUrl)));

                options.AddProperty("iconCls", className);
            }

            return(iconScript + String.Format("{0}.addTab({1});", ScriptID, options));
        }
Beispiel #6
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 jsContent = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Beispiel #7
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region Reset ActiveIndex

            // 重置面板的 Collapsed 属性
            if (ActivePane != null)
            {
                foreach (AccordionPane pane in Panes)
                {
                    pane.Collapsed = true;
                }

                ActivePane.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

            OB.RemoveProperty("layout");

            JsObjectBuilder configBuilder = new JsObjectBuilder();
            configBuilder.AddProperty("animate", false);
            configBuilder.AddProperty("activeOnTop", EnableActiveOnTop);
            configBuilder.AddProperty("fill", EnableFill);
            configBuilder.AddProperty("hideCollapseTool", !ShowCollapseTool);
            configBuilder.AddProperty("type", "accordion");

            //configBuilder.AddProperty("multi", true);

            OB.AddProperty("layout", configBuilder);

            #endregion


            string jsContent = String.Format("var {0}=Ext.create('Ext.panel.Panel',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Beispiel #8
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            string message = "";
            string title   = "";

            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }


            JsObjectBuilder jsOB = new JsObjectBuilder();

            if (!String.IsNullOrEmpty(CancelScript))
            {
                jsOB.AddProperty("cancel", CancelScript);
            }

            if (!String.IsNullOrEmpty(OkScript))
            {
                jsOB.AddProperty("ok", OkScript);
            }

            if (Target != Target.Self)
            {
                jsOB.AddProperty("target", TargetHelper.GetName(Target));
            }

            if (MessageBoxIcon != MessageBoxIcon.Warning)
            {
                jsOB.AddProperty("messageIcon", MessageBoxIconHelper.GetShortName(MessageBoxIcon));
            }

            if (!String.IsNullOrEmpty(title))
            {
                jsOB.AddProperty("title", title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }

            if (!String.IsNullOrEmpty(message))
            {
                jsOB.AddProperty("message", JsHelper.EnquoteWithScriptTag(message.Replace("\r\n", "\n").Replace("\n", "<br/>")), true);
            }

            return(String.Format("F.confirm({0});", jsOB.ToString()));
        }
Beispiel #9
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            if (Layout != Layout.Container)
            {
                //OB.AddProperty("layout", LayoutHelper.GetName(Layout));
                string layoutName = LayoutHelper.GetName(Layout);

                JsObjectBuilder layoutConfigOB = new JsObjectBuilder();
                if (Layout == Layout.Table)
                {
                    layoutConfigOB.AddProperty("columns", TableConfigColumns);
                }
                else if (Layout == Layout.HBox || Layout == Layout.VBox)
                {
                    if (BoxConfigAlign != BoxLayoutAlign.Top)
                    {
                        layoutConfigOB.AddProperty("align", BoxLayoutAlignHelper.GetName(BoxConfigAlign, Layout));
                    }

                    if (BoxConfigPosition != BoxLayoutPosition.Left)
                    {
                        layoutConfigOB.AddProperty("pack", BoxLayoutPositionHelper.GetName(BoxConfigPosition));
                    }

                    if (BoxConfigPadding != "0")
                    {
                        layoutConfigOB.AddProperty("padding", BoxConfigPadding);
                    }

                    if (BoxConfigChildMargin != "0")
                    {
                        layoutConfigOB.AddProperty("defaultMargins", BoxConfigChildMargin);
                    }
                }

                if (layoutConfigOB.Count > 0)
                {
                    layoutConfigOB.AddProperty("type", layoutName);

                    OB.AddProperty("layout", layoutConfigOB);
                }
                else
                {
                    OB.AddProperty("layout", layoutName);
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            string message = "";
            string title   = "";

            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }

            JsObjectBuilder jsOB = new JsObjectBuilder();

            if (Target != Target.Self)
            {
                jsOB.AddProperty("target", TargetHelper.GetName(Target));
            }

            if (NotifyIcon != NotifyIcon.Info)
            {
                jsOB.AddProperty("notifyIcon", NotifyIconHelper.GetName(NotifyIcon));
            }

            if (!String.IsNullOrEmpty(title))
            {
                jsOB.AddProperty("title", title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }

            if (!String.IsNullOrEmpty(message))
            {
                jsOB.AddProperty("message", JsHelper.EnquoteWithScriptTag(message.Replace("\r\n", "\n").Replace("\n", "<br/>")), true);
            }

            return(String.Format("F.notify({0});", jsOB.ToString()));
        }
Beispiel #11
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();


            OB.AddProperty("border", false);
            OB.AddProperty("header", false);

            Form parentForm = Parent as Form;

            if (parentForm == null)
            {
                return;
            }

            int formrowItemsSpace = Convert.ToInt32(parentForm.FormRowItemsSpace.Value);


            if (Items.Count > 0)
            {
                #region oldcode

                /*
                 * 增加中间的分割面板,会对显示隐藏表单字段造成影响
                 * int currentItemCount = 0;
                 * JsArrayBuilder ab = new JsArrayBuilder();
                 * foreach (ControlBase item in Items)
                 * {
                 *  if (item.Visible)
                 *  {
                 *      if (currentItemCount > 0)
                 *      {
                 *          OptionBuilder separatorOB = new OptionBuilder();
                 *          separatorOB.AddProperty("type", "panelbase");
                 *          separatorOB.AddProperty("width", 8);
                 *          ab.AddProperty(String.Format("{0}", separatorOB), true);
                 *      }
                 *      ab.AddProperty(String.Format("{0}", item.XID), true);
                 *      currentItemCount++;
                 *  }
                 * }
                 * OB.AddProperty("items", ab.ToString(), true);
                 */

                #endregion

                // 为子项添加布局属性
                int           columnCount           = Items.Count;
                string        defaultColumnWidthStr = (1.0 / columnCount).ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
                List <string> columnWidths          = GetTrimedColumnWidths();

                // 用户自定义ColumnWidths是否和Items的个数匹配
                bool isColumnWidthsMatch = false;
                if (columnWidths.Count == columnCount)
                {
                    isColumnWidthsMatch = true;
                }

                Dictionary <string, JsObjectBuilder> buttonOptions = new Dictionary <string, JsObjectBuilder>();
                for (int i = 0; i < columnCount; i++)
                {
                    var comp = Items[i] as Component;

                    // 如果FormRow的子项是 Button,则用一个面板将其包裹起来,否则按钮的宽度会很长
                    bool            isbutton      = false;
                    JsObjectBuilder buttonPanelOB = new JsObjectBuilder();
                    if (comp is Button)
                    {
                        isbutton = true;

                        buttonPanelOB.AddProperty("xtype", "panel");
                        buttonPanelOB.AddProperty("header", false);
                        buttonPanelOB.AddProperty("border", false);

                        buttonPanelOB.AddProperty("items", String.Format("[{0}]", comp.XID), true);
                    }

                    #region Component
                    if (comp != null)
                    {
                        // 不是最后一列的话,加上空白间隔
                        if (columnCount > 1 && i != columnCount - 1)
                        {
                            if (isbutton)
                            {
                                //buttonOB.AddProperty("marginRight", formrowItemsSpace);
                                buttonPanelOB.AddProperty("style", String.Format("margin-right:{0}px;", formrowItemsSpace));
                            }
                            else
                            {
                                //// 如果尚未设置 MarginRight
                                //if (comp.MarginRight == Unit.Empty)
                                //{
                                //    comp.MarginRight = Unit.Pixel(formrowItemsSpace);
                                //}
                                //if (String.IsNullOrEmpty(comp.Margin))
                                //{
                                //    comp.Margin = String.Format("0 {0} 0 0", formrowItemsSpace);
                                //}
                                comp.CssStyle += String.Format("margin-right:{0}px;", formrowItemsSpace);
                            }
                        }
                    }
                    #endregion

                    #region BoxComponent
                    var boxcomp = comp as BoxComponent;
                    if (boxcomp != null)
                    {
                        if (isColumnWidthsMatch)
                        {
                            string columnWidth = StringUtil.ConvertPercentageToDecimalString(columnWidths[i]);
                            if (Convert.ToDouble(columnWidth) <= 1.0)
                            {
                                if (isbutton)
                                {
                                    buttonPanelOB.AddProperty("columnWidth", columnWidth, true);
                                }
                                else
                                {
                                    boxcomp.ColumnWidth = columnWidth;
                                }
                            }
                            else
                            {
                                Unit unitColumnWidth = Unit.Parse(columnWidth);

                                if (isbutton)
                                {
                                    buttonPanelOB.AddProperty("width", unitColumnWidth.Value);
                                }
                                else
                                {
                                    boxcomp.Width = unitColumnWidth;
                                }
                            }
                        }
                        else
                        {
                            if (isbutton)
                            {
                                buttonPanelOB.AddProperty("columnWidth", defaultColumnWidthStr, true);
                            }
                            else
                            {
                                boxcomp.ColumnWidth = defaultColumnWidthStr;
                            }
                        }
                    }
                    #endregion

                    if (isbutton)
                    {
                        buttonOptions.Add(comp.XID, buttonPanelOB);
                    }
                }


                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (ControlBase item in Items)
                {
                    if (item.Visible)
                    {
                        string itemXID = item.XID;
                        if (buttonOptions.ContainsKey(itemXID))
                        {
                            itemXID = buttonOptions[itemXID].ToString();
                        }

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

            // 自定义样式
            OB.AddProperty("cls", "f-formrow");

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

            ////// 目的:子控件的JS代码在父控件的前面
            ////AddStartupScript(this, String.Empty);
            //AddStartupScript(String.Empty);
        }
Beispiel #12
0
        protected override void OnFirstPreRender()
        {
            // 确保 X_Rows 在页面第一次加载时都存在于x_state中
            XState.AddModifiedProperty("X_Rows");

            // 因为可以在 ASPX 中指定列的 Hidden 属性
            // 如果在 ASPX 中指定了列的 Hidden 属性,但是 HiddenColumnIndexArray 不在改变的属性列表中,
            // 为了在客户端初始化隐藏的列,需要手工将 HiddenColumnIndexArray 添加到改变的属性列表中,以便使其存在于 x_state 属性中。
            if (HiddenColumnIndexArray.Length > 0)
            {
                XState.AddModifiedProperty("HiddenColumnIndexArray");
            }

            // 不需要手工添加 SelectedRowIndexArray 属性,是因为只能通过代码设置此属性

            base.OnFirstPreRender();

            ResourceManager.Instance.AddJavaScriptComponent("grid");

            // 分页工具栏使用了 Ext.form.NumberField 组件,所以必须引入 form 的JavaScript
            if (AllowPaging)
            {
                ResourceManager.Instance.AddJavaScriptComponent("form");
            }

            //OB.Listeners.AddProperty("rowmousedown", "function(){alert('ok');}", true);

            string cls = CssClass;

            #region selectModel/gridStore/gridColumn

            #region old code
            //string dataScript = "var grid_data=[['My_Item1The id of a column in this grid that should expand to fill unused space. This id can not be 0.','1','2008'],['My_Item2','2','2007']];";
            //string storeScript = "var grid_store = new Ext.data.SimpleStore({fields:[{name:'name1'},{name:'value'},{name:'year'}]});\r\ngrid_store.loadData(grid_data);";
            //string storeScript = "var grid_store = new Ext.data.SimpleStore({fields:['name1','value1','year1'],data:[['My_Item1The id of a column in this grid that should expand to fill unused space. This id can not be 0.','1','2008'],['My_Item2','2','2007']]});";
            //OB.AddProperty(OptionName.Columns, "[{id:'name2', header: 'Price', sortable: true},{header: 'Price2', sortable: true},{header: 'Price3', sortable: true}]", true);

            #endregion

            string gridSelectModelScript = GetGridSelectModel();
            OB.AddProperty("sm", Render_SelectModelID, true);
            //OB.AddProperty("disableSelection", true);

            string gridColumnsScript = GetGridColumnScript();
            OB.AddProperty("cm", Render_GridColumnModelID, true);
            //if (!String.IsNullOrEmpty(RowExpander.DataFormatString))
            //{
            //    OB.AddProperty("plugins", Render_GridRowExpanderID, true);
            //}

            string gridStoreScript = GetGridStore();
            OB.AddProperty("store", Render_GridStoreID, true);

            //Console.WriteLine(RowExpander.DataFields);

            #endregion

            #region Width

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

            string autoExpandColumnID = AutoExpandColumn; // GetAutoExpandColumnID();
            if (String.IsNullOrEmpty(autoExpandColumnID))
            {
                autoExpandColumnID = GetAutoExpandColumnID();
            }

            if (!String.IsNullOrEmpty(autoExpandColumnID))
            {
                OB.AddProperty("autoExpandColumn", autoExpandColumnID);

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

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

            #endregion

            #region viewConfig

            JsObjectBuilder viewBuilder = new JsObjectBuilder();
            if (ForceFitAllTime)
            {
                viewBuilder.AddProperty("forceFit", true);
            }
            if (ForceFitFirstTime)
            {
                viewBuilder.AddProperty("autoFill", true);
            }

            if (VerticalScrollWidth != Unit.Empty)
            {
                viewBuilder.AddProperty("scrollOffset", VerticalScrollWidth.Value);
            }

            if (!String.IsNullOrEmpty(EmptyText))
            {
                viewBuilder.AddProperty("deferEmptyText", false);
                viewBuilder.AddProperty("emptyText", EmptyText);
            }

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

            #endregion

            #region Properties

            if (EnableColumnLines)
            {
                OB.AddProperty("columnLines", true);
            }

            OB.AddProperty("enableHdMenu", EnableHeaderMenu);

            if (EnableHeaderMenu)
            {
                // 启用标题栏菜单,但是不启用标题栏菜单中的隐藏列功能
                if (!EnableColumnHide)
                {
                    OB.AddProperty("enableColumnHide", false);
                }
            }

            if (EnableAlternateRowColor)
            {
                OB.AddProperty("stripeRows", true);
            }

            if (!ShowGridHeader)
            {
                OB.AddProperty("hideHeaders", true);
            }

            if (!EnableMouseOverColor)
            {
                OB.AddProperty("trackMouseOver", false);
            }

            // 延迟渲染
            if (!EnableDelayRender)
            {
                OB.AddProperty("deferRowRender", false);
            }

            #endregion

            #region EnableRowClickEvent

            if (EnableRowClickEvent)
            {
                string validateScript = "var args='RowClick$'+rowIndex;";
                validateScript += GetPostBackEventReference("#RowClick#").Replace("'#RowClick#'", "args");

                string rowClickScript = String.Format("function(grid,rowIndex,e){{{0}}}", validateScript);

                OB.Listeners.AddProperty("rowclick", rowClickScript, true);
            }

            if (EnableRowDoubleClickEvent)
            {
                string validateScript = "var args='RowDoubleClick$'+rowIndex;";
                validateScript += GetPostBackEventReference("#RowDoubleClick#").Replace("'#RowDoubleClick#'", "args");

                string rowClickScript = String.Format("function(grid,rowIndex,e){{{0}}}", validateScript);

                OB.Listeners.AddProperty("rowdblclick", rowClickScript, true);
            }

            #endregion

            #region AllowPaging

            string pagingScript = String.Empty;
            if (AllowPaging)
            {
                JsObjectBuilder pagingBuilder = GetPagingBuilder();

                pagingBuilder.AddProperty("displayInfo", true);
                //pagingBuilder.AddProperty("store", Render_GridStoreID, true);
                //// Hide refresh button, we don't implement this logic now.
                //pagingBuilder.Listeners.AddProperty("beforerender", JsHelper.GetFunction("this.x_hideRefresh();"), true);

                string postbackScript = String.Empty;
                postbackScript = GetPostBackEventReference("#PLACEHOLDER#");
                string loadPageScript = JsHelper.GetFunction(postbackScript.Replace("'#PLACEHOLDER#'", "'Page$'+pageIndex"), "pageIndex");

                pagingBuilder.AddProperty("onLoadPage", loadPageScript, true);

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

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

                pagingScript = String.Format("var {0}=new Ext.ux.SimplePagingToolbar({1});", Render_PagingID, pagingBuilder);

                OB.AddProperty("bbar", Render_PagingID, true);
            }

            #endregion

            #region old code

            //string checkBoxFieldScript = String.Empty;
            //int columnIndex = 0;
            //List<int> needPersistStateColumnIndexList = new List<int>();
            //foreach (GridColumn column in Columns)
            //{
            //    if (column is CheckBoxField)
            //    {
            //        CheckBoxField checkBoxField = column as CheckBoxField;

            //        if (!checkBoxField.RenderAsStaticField)
            //        {
            //            // check -> uncheck
            //            //string checkScript = String.Format("ele.toggleClass('box-grid-checkbox-uncheck');var domValue=Ext.get('{0}').dom.value;var rowValueIndex=domValue.indexOf(rowIndex+',');if(rowValueIndex>=0){{Ext.get('{0}').dom.value=domValue.replace(rowIndex+',','');}}else{{return;}}", GetNeedPersistStateColumnIndexID(columnIndex));
            //            //string uncheckScript = String.Format("ele.toggleClass('box-grid-checkbox-uncheck');var domValue=Ext.get('{0}').dom.value;var rowValueIndex=domValue.indexOf(rowIndex+',');if(rowValueIndex>=0){{return;}}else{{Ext.get('{0}').dom.value+=rowIndex+',';}}", GetNeedPersistStateColumnIndexID(columnIndex));

            //            //string checkScript = String.Format("ele.toggleClass('box-grid-checkbox-uncheck');X.util.removeValueFromHiddenField('{0}',rowIndex);", GetNeedPersistStateColumnIndexID(columnIndex));
            //            //string uncheckScript = String.Format("ele.toggleClass('box-grid-checkbox-uncheck');X.util.addValueToHiddenField('{0}',rowIndex);", GetNeedPersistStateColumnIndexID(columnIndex));

            //            string checkScript = "ele.toggleClass('box-grid-checkbox-uncheck');";
            //            string uncheckScript = "ele.toggleClass('box-grid-checkbox-uncheck');";

            //            checkBoxFieldScript += String.Format("{0}_checkbox{1}=function(e,ele,rowIndex){{var ele=Ext.get(ele);if(ele.hasClass('box-grid-checkbox-uncheck')){{{2}}}else{{{3}}}}};", XID, columnIndex, uncheckScript, checkScript);
            //            //checkBoxFieldScript += "\r\n";

            //            needPersistStateColumnIndexList.Add(columnIndex);
            //        }
            //    }
            //    columnIndex++;
            //}

            //NeedPersistStateColumnIndexArray = needPersistStateColumnIndexList.ToArray();

            #endregion

            #region old code

            //string hiddenFieldsScript = String.Empty;

            //hiddenFieldsScript += GetSetHiddenFieldValueScript(SelectedRowIndexArrayHiddenFieldID, StringUtil.GetStringFromIntArray(SelectedRowIndexArray));

            //// 有这些列需要保存状态
            //if (NeedPersistStateColumnIndexArray != null && NeedPersistStateColumnIndexArray.Length > 0)
            //{
            //    foreach (int needStateColumnIndex in NeedPersistStateColumnIndexArray)
            //    {
            //        hiddenFieldsScript += GetSetHiddenFieldValueScript(GetNeedPersistStateColumnIndexID(needStateColumnIndex), Columns[needStateColumnIndex].SaveColumnState());
            //    }
            //}

            //hiddenFieldsScript += "\r\n";
            #endregion

            #region remove fx

            OB.AddProperty("draggable", false);
            OB.AddProperty("enableColumnMove", false);
            OB.AddProperty("enableDragDrop", false);

            #endregion

            #region AllowSorting

            // 如果启用服务器端排序,则需要注册headerclick事件处理
            if (AllowSorting)
            {
                #region old code
                ////string argumentStr = "var field=sortInfo.field.substr(sortInfo.field.indexOf('__')+2);var args='Sort$'+field+'$'+ sortInfo.direction;";
                //string argumentStr = "var args='Sort$'+sortInfo.field;";
                //string postBackReference = String.Format("{1}__doPostBack('{0}',args);return false;", ClientID, argumentStr);

                //string sortChangeScript = String.Format("function(grid,sortInfo){{{0}}}", postBackReference);
                //OB.Listeners.AddProperty(OptionName.Sortchange, sortChangeScript, true);

                // 下面这个规则不再使用,因为会引入中文,导致Ext.get('Grid1').select 函数出错
                // 还要进行验证:序号列和多选框列不能排序,没有设置SortField的列也不能排序
                // 规则:如果此列的dataIndex为空,表示不是数据列(就是序号列或多选框列),
                // 如果dataIndex为"c0__MyText",表示排序字段是"MyText",如果dataIndex为"c2",表示没有定义排序列
                //string validateScript = "var dataIndex=grid.initialConfig.columns[columnIndex].dataIndex;if(dataIndex==''||dataIndex.indexOf('__')<0){return false;}";

                //string validateScript = "var dataIndex=grid.getColumnModel().getDataIndex(columnIndex);if(dataIndex==''||dataIndex.indexOf('__')<0){return false;}";
                #endregion

                string headerClickScript = "if(!cmp.getColumnModel().config[columnIndex].sortable){return false;}";
                headerClickScript += "var args='Sort$'+columnIndex;";
                headerClickScript += GetPostBackEventReference("#SORT#").Replace("'#SORT#'", "args");

                // 告诉 store 本次排序已经处理了,不要重复处理了
                headerClickScript += "cmp.getStore().headerclickprocessed=true;";

                //string headerClickScript = String.Format("function(grid,columnIndex){{{0}}}", validateScript);
                OB.Listeners.AddProperty("headerclick", JsHelper.GetFunction(headerClickScript, "cmp", "columnIndex"), true);

                #region old code
                //string sortIconScript = GetSortIconScript();

                //if (_FineUIAjaxColumnsChanged)
                //{
                //    // 如果列都发生了变化,需要重新设置图标
                //    AddAjaxPropertyChangedScript(sortIconScript);
                //}
                //else
                //{
                //    if (AjaxPropertyChanged("SortIconScript", sortIconScript))
                //    {
                //        AddAjaxPropertyChangedScript(sortIconScript);
                //    }
                //}

                //renderSB.Append(sortIconScript);

                //// For these columns need sorted, show the cursor pointer.
                //List<string> columnIDList = new List<string>();
                //foreach (GridColumn column in Columns)
                //{
                //    if (!String.IsNullOrEmpty(column.SortField))
                //    {
                //        columnIDList.Add(column.ColumnID);
                //    }
                //}

                //// 存在需要排序的列
                //if (columnIDList.Count > 0)
                //{
                //    string cursorScript = String.Format("Ext.each({0},{1});", JsHelper.GetJsStringArray(columnIDList.ToArray()),
                //        String.Format("function(item){{Ext.get('{0}').select('.x-grid3-hd-row .x-grid3-td-'+item).addClass('cursor-pointer');}}", ClientID));

                //    renderSB.Append(cursorScript);

                //    if (_FineUIAjaxColumnsChanged)
                //    {
                //        // 如果列都发生了变化,需要重新需要排序的列,显示为手型的光标
                //        AddAjaxPropertyChangedScript(cursorScript);
                //    }
                //}
                #endregion
            }

            #endregion

            #region Listeners - render - viewready

            StringBuilder viewreadySB = new StringBuilder();

            // Note: this.x_state['X_Rows']['Values'] will always rendered to the client side.
            //viewreadySB.Append("cmp.x_updateTpls();");

            if (AllowSorting)
            {
                // After the grid is rendered, then we can apply sort icon to grid header.
                viewreadySB.AppendFormat("cmp.x_setSortIcon({0}, '{1}');", SortColumnIndex, SortDirection);
            }

            if (!AllowCellEditing)
            {
                viewreadySB.Append("cmp.x_selectRows();");
            }

            if (EnableTextSelection)
            {
                //OB.AddProperty("cls", CssClass + " x-grid-selectable");
                cls += " x-grid-selectable";

                viewreadySB.Append("cmp.x_enableTextSelection();");
            }

            OB.Listeners.AddProperty("viewready", JsHelper.GetFunction(viewreadySB.ToString(), "cmp"), true);

            #endregion

            #region cls

            if (RowVerticalAlign != VerticalAlign.Middle)
            {
                cls += String.Format("row-align-{0}", VerticalAlignName.GetName(RowVerticalAlign));
            }

            cls = cls.Trim();
            if (!String.IsNullOrEmpty(cls))
            {
                OB.AddProperty("cls", cls);
            }

            #endregion

            #region Listeners - render

            StringBuilder renderSB = new StringBuilder();

            // 加载表格数据
            renderSB.Append("cmp.x_loadData();");

            // 隐藏列
            if (HiddenColumnIndexArray != null && HiddenColumnIndexArray.Length > 0)
            {
                renderSB.Append("cmp.x_updateColumnsHiddenStatus();");
            }

            // 展开所有的行扩展列
            if (ExpandAllRowExpanders)
            {
                renderSB.Append("cmp.x_expandAllRows();");
            }

            OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderSB.ToString(), "cmp"), true);

            #endregion

            #region AllowCellEditing

            if (AllowCellEditing)
            {
                if (ClicksToEdit != 2)
                {
                    OB.AddProperty("clicksToEdit", ClicksToEdit);
                }

                //OB.Listeners.AddProperty("beforeedit", JsHelper.GetFunction("console.log(e);", "e"), true);

                //OB.Listeners.AddProperty("afteredit", JsHelper.GetFunction("console.log(e);", "e"), true);

                OB.AddProperty("x_newAddedRows", "[]", true);
            }

            #endregion

            StringBuilder sb = new StringBuilder();
            sb.Append(gridSelectModelScript + gridStoreScript + pagingScript + gridColumnsScript);
            sb.AppendFormat("var {0}=new Ext.grid.{2}({1});", XID, OB, AllowCellEditing ? "EditorGridPanel" : "GridPanel");

            AddStartupScript(sb.ToString());

            #region old code

            ////List<string> totalModifiedProperties = XState.GetTotalModifiedProperties();
            ////if (SelectedRowIndexArray.Length > 0)
            ////{
            ////    string selectScript = String.Empty;
            ////    if (totalModifiedProperties.Contains("SelectedRowIndexArray"))
            ////    {
            ////        selectScript = String.Format("{0}.x_selectRows();", XID);
            ////    }
            ////    else
            ////    {
            ////        selectScript = String.Format("{0}.selectRows({1});", Render_SelectModelID, new JArray(SelectedRowIndexArray));
            ////    }
            ////    sb.Append(JsHelper.GetDeferScript(selectScript, 200));
            ////}

            //// Make sure SelectedRowIndexArray property exist in X_STATE during page's first load.
            //sb.Append(JsHelper.GetDeferScript(String.Format("{0}.x_selectRows();", XID), 200));

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

            // 不渲染
            RenderWrapperNode = false;

            // 这个是必须的,2009-08-04
            // 因为每个页面都会有 PageManager 控件,每个页面要至少调用 GetPostBackEventReference 一次,以在页面产生 __doPostBack 函数。
            Page.ClientScript.GetPostBackEventReference(this, "");

            // Move it to ResourceManager.cs
            // 为页面的 Form 添加 autocomplete="off" 属性
            // 参考http://www.cnblogs.com/sanshi/archive/2009/09/04/1560146.html#1635830
            // Page.Form.Attributes["autocomplete"] = "off";

            #region HideScrollbars

            if (HideScrollbars)
            {
                //if (Page.Request.UserAgent.ToLower().Contains("msie"))
                //{
                //    //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "noscroll", String.Format("window.document.body.scroll='no';"), true);
                //    AddStartupAbsoluteScript("window.document.body.scroll='no';");
                //}
                //else
                //{
                //    //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "noscroll",  String.Format("window.document.body.style.overflow='hidden';"), true);
                //    AddStartupAbsoluteScript("window.document.body.style.overflow='hidden';");
                //}
                AddStartupAbsoluteScript("F.util.hideScrollbar();");
            }

            #endregion

            #region PageLoading



            if (!PageLoadingControlExist)
            {
                string jsContent = String.Empty;

                if (EnablePageLoading)
                {
                    jsContent += "F.util.removePageLoading(false);";
                }

                AddStartupAbsoluteScript(jsContent);
            }


            #endregion

            //#region EnableAjax

            //if (!EnableAjax)
            //{
            //    AddStartupAbsoluteScript("F.global_disable_ajax=true;");
            //}

            //#endregion

            #region AutoSizePanelID

            if (!String.IsNullOrEmpty(AutoSizePanelID))
            {
                PanelBase autosizePanel = ControlUtil.FindControl(Page.Form, AutoSizePanelID) as PanelBase;

                if (autosizePanel != null)
                {
                    #region oldcode
                    //string resizePanelScript = String.Empty;

                    //resizePanelScript += String.Format("{0}_resize_outerpanel=function(){{var panel=Ext.getCmp('{1}');panel.setSize(Ext.getBody().getSize());panel.doLayout();}};", ClientJavascriptID, panel.ClientID);
                    //resizePanelScript += String.Format("{0}_resize_outerpanel();", ClientJavascriptID);
                    //resizePanelScript += String.Format("if(Ext.isIE){{X.{0}_resize_outerpanel.defer(60);}}", ClientJavascriptID);
                    //resizePanelScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}_resize_outerpanel();}},box);", ClientJavascriptID);

                    //AddAbsoluteStartupScript(resizePanelScript);

                    // X._3=new Ext.FormViewport({renderTo:"RegionPanel1_wrapper",id:"RegionPanel1",layout:"border",items:[X._1,X._2],bodyStyle:"",border:false,animCollapse:false});

                    #endregion

                    // 子节点不向页面输出HTML,此PageManager向页面输出HTML
                    autosizePanel.RenderWrapperNode = false;
                    RenderWrapperNode = true;

                    OB.AddProperty("layout", "fit");
                    OB.AddProperty("border", false);
                    OB.AddProperty("items", String.Format("{0}", autosizePanel.XID), true);

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

                    AddStartupAbsoluteScript(jsContent);
                }
            }

            #endregion

            //if (EnableBigFont)
            //{
            //    AddStartupAbsoluteScript("Ext.getBody().addClass('bigfont');");
            //}

            #region oldcode

            // Move to F.util.init
            // Asp.Net Buttons(type="submit")
            // AddStartupAbsoluteScript("F.util.makeAspnetSubmitButtonAjax();");

            #endregion

            JsObjectBuilder job = new JsObjectBuilder();

            job.AddProperty("name", UniqueID);

            if (ValidateForms != null && ValidateForms.Length > 0)
            {
                JsObjectBuilder validate = new JsObjectBuilder();
                validate.AddProperty("forms", ControlUtil.GetControlClientIDs(ValidateForms));
                validate.AddProperty("target", TargetHelper.GetName(ValidateTarget));
                validate.AddProperty("messagebox", ValidateMessageBox.ToString().ToLower());
                job.AddProperty("validate", validate);
            }

            string createScript = String.Format("F.pagemanager={1};", XID, job);
            AddStartupScript(createScript);
        }
Beispiel #14
0
        /// <summary>
        /// 取得页面初始化时脚本
        /// </summary>
        /// <param name="script"></param>
        /// <returns></returns>
        private string GetStartupScript(string script)
        {
            #region beforeBuilder

            StringBuilder beforeBuilder = new StringBuilder();

            //beforeBuilder.Append("F.init();");

            // ExtJS2.2的BUG,Ext.onReady会被调用两次(在ExtJS 2.2.1中已经修正)
            // Ext.onReady在extjsv3.1.0中依然有问题,在IE下有时会导致页面空白,不能继续执行,只有在点击Stop按钮或者重新刷新后才行。
            // http://www.extjs.net/forum/showthread.php?t=69437
            // http://www.extjs.com/forum/showthread.php?p=347524#post347524
            // https://extjs.net/forum/showthread.php?t=86948
            //beforeBuilder.Append("if(X.initialized){return;}X.initialized=true;");

            // 空白图片,只在 IE6 和 IE7 下设置(默认为 http://www.sencha.com/s.gif ),其他浏览器下使用 data URL
            //beforeBuilder.AppendFormat("if(Ext.isIE6||Ext.isIE7){{Ext.BLANK_IMAGE_URL='{0}';}}", ResourceHelper.GetWebResourceUrl("FineUI.res.img.s.gif"));

            //beforeBuilder.Append("F.util.init();");

            // form 相关配置
            //beforeBuilder.Append("var fieldPro=Ext.form.Base.prototype;");
            //beforeBuilder.AppendFormat("fieldPro.msgTarget='{0}';", MsgTargetHelper.GetName(PageManager.Instance.FormMessageTarget));
            //beforeBuilder.AppendFormat("fieldPro.labelWidth={0};", PageManager.Instance.FormLabelWidth.Value);
            //beforeBuilder.AppendFormat("fieldPro.labelSeparator='{0}';", PageManager.Instance.FormLabelSeparator);
            //beforeBuilder.AppendFormat("F.util.init('{0}',{1},'{2}','{3}',{4},'{5}',{6},'{7}',{8});",
            //    MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget),
            //    PageManager.Instance.FormLabelWidth.Value,
            //    PageManager.Instance.FormLabelSeparator,
            //    //PageManager.Instance.EnableBigFont.ToString().ToLower(),
            //    Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()), //String.Format("{0}/res/images/s.gif", GlobalConfig.GetExtjsBasePath())), //ResourceHelper.GetWebResourceUrlResAxd("FineUI.res.img.s.gif&v=1"),
            //    //PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(),
            //    PageManager.Instance.EnableAjaxLoading.ToString().ToLower(),
            //    AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType),
            //    PageManager.Instance.EnableAjax.ToString().ToLower(),
            //    ThemeHelper.GetName(PageManager.Instance.Theme),
            //    PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower()
            //    );


            //beforeBuilder.AppendFormat("F.util.init('{0}',{1},'{2}','{3}',{4},'{5}',{6},'{7}',{8});",
            //    MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget),
            //    PageManager.Instance.FormLabelWidth.Value,
            //    PageManager.Instance.FormLabelSeparator,
            //    //PageManager.Instance.EnableBigFont.ToString().ToLower(),
            //    Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()), //String.Format("{0}/res/images/s.gif", GlobalConfig.GetExtjsBasePath())), //ResourceHelper.GetWebResourceUrlResAxd("FineUI.res.img.s.gif&v=1"),
            //    //PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(),
            //    PageManager.Instance.EnableAjaxLoading.ToString().ToLower(),
            //    AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType),
            //    PageManager.Instance.EnableAjax.ToString().ToLower(),
            //    ThemeHelper.GetName(PageManager.Instance.Theme),
            //    PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower()
            //    );

            JsObjectBuilder initObj = new JsObjectBuilder();

            if (PageManager.Instance.FormMessageTarget != ConfigPropertyValue.FORM_MESSAGETARGET_DEFAULT)
            {
                initObj.AddProperty("msgTarget", MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget));
            }

            if (PageManager.Instance.FormLabelWidth != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                initObj.AddProperty("labelWidth", PageManager.Instance.FormLabelWidth.Value);
            }

            if (PageManager.Instance.FormLabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                initObj.AddProperty("labelSeparator", PageManager.Instance.FormLabelSeparator);
            }

            //initObj.AddProperty("blankImageUrl", Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()));

            if (PageManager.Instance.EnableAjaxLoading != ConfigPropertyValue.ENABLE_AJAX_LOADING_DEFAULT)
            {
                initObj.AddProperty("enableAjaxLoading", PageManager.Instance.EnableAjaxLoading.ToString().ToLower());
            }

            if (PageManager.Instance.AjaxLoadingType != ConfigPropertyValue.AJAX_LOADING_TYPE_DEFAULT)
            {
                initObj.AddProperty("ajaxLoadingType", AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType));
            }

            if (PageManager.Instance.EnableAjax != ConfigPropertyValue.ENABLE_AJAX_DEFAULT)
            {
                initObj.AddProperty("enableAjax", PageManager.Instance.EnableAjax.ToString().ToLower());
            }

            if (PageManager.Instance.Theme != Theme.Neptune)
            {
                initObj.AddProperty("theme", ThemeHelper.GetName(PageManager.Instance.Theme));
            }

            if (PageManager.Instance.Language != ConfigPropertyValue.LANGUAGE_DEFAULT)
            {
                initObj.AddProperty("language", LanguageHelper.GetName(PageManager.Instance.Language));
            }



            if (PageManager.Instance.EnableFormChangeConfirm)
            {
                initObj.AddProperty("formChangeConfirm", PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower());
            }

            if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT)
            {
                initObj.AddProperty("ajaxTimeout", PageManager.Instance.AjaxTimeout);
            }

            initObj.AddProperty("_version", GlobalConfig.ProductVersion);

            beforeBuilder.AppendFormat("F.init({0});", initObj);

            //if (PageManager.Instance.BeforeAjaxPostBackScript != String.Empty)
            //{
            //    beforeBuilder.AppendFormat("F.util.beforeAjaxPostBackScript=function(){{{0}}};", PageManager.Instance.BeforeAjaxPostBackScript);
            //}

            //beforeBuilder.Append("F.ajax.hookPostBack();");

            //if (PageManager.Instance.EnableAjax)
            //{
            //    if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT)
            //    {
            //        beforeBuilder.AppendFormat("Ext.Ajax.timeout={0};", PageManager.Instance.AjaxTimeout * 1000);
            //    }
            //}

            //if (PageManager.Instance.EnableBigFont)
            //{
            //    beforeBuilder.Append("Ext.getBody().addCls('bigfont');");
            //}


            // WindowGroup
            //beforeBuilder.AppendFormat("{0}=new Ext.WindowGroup();{0}.zseed=6000;", WINDOW_DEFAULT_GROUP_ID);

            //// CookieProvider
            //beforeBuilder.AppendFormat("{0}=new Ext.state.CookieProvider();", COOKIE_PROVIDER_ID);

            //// HiddenFields
            //beforeBuilder.AppendFormat("{0}=[];", HIDDEN_FIELDS_ID);

            // 保存页面中可输入的表单字段状态是否发生变化的隐藏字段
            //innderBuilder.AppendFormat("var sn=document.createElement('input');sn.type='hidden';sn.value='false';sn.id=sn.name='{0}';Ext.getBody().query('form')[0].appendChild(sn);", PAGE_STATE_CHANGED_ID);
            //innderBuilder.AppendFormat("Ext.DomHelper.append(document.forms[0],{{tag:'input',type:'hidden',value:'false',id:'{0}',name:'{0}'}});", PAGE_STATE_CHANGED_ID);
            //beforeBuilder.AppendFormat("F.util.setHiddenFieldValue('{0}','false');", PAGE_STATE_CHANGED_ID);

            // 5.预加载图片
            //beforeBuilder.AppendFormat("{0}=[];", PRELOAD_IMAGES_ID);
            //beforeBuilder.AppendFormat("{0}.push('{1}');", PRELOAD_IMAGES_ID, ResourceHelper.GetWebResourceUrl(Page, "FineUI.res.img.default.form.error-tip-corners.gif"));
            //beforeBuilder.AppendFormat("box_preloadImages({0});", PRELOAD_IMAGES_ID);

            #endregion

            #region afterBuilder

            //StringBuilder afterBuilder = new StringBuilder();

            //afterBuilder.Append("\r\n");

            // 注册隐藏字段
            //string hiddenFieldScript = "var itemNode=Ext.get(item[0]);if(itemNode==null){Ext.DomHelper.append(document.forms[0],{tag:'input',type:'hidden',value:item[1],id:item[0],name:item[0]});}else{itemNode.dom.value=item[1];}";
            //afterBuilder.AppendFormat("Ext.each({0},function(item){{{1}}},box);", HIDDEN_FIELDS_ID, hiddenFieldScript);
            //afterBuilder.Append("box_alertDEBUG();");

            //afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}");
            //afterBuilder.Append("F.util.triggerReady();");
            //// 如果是回发并且允许回发注册onReady脚本
            //if (!Page.IsPostBack || (Page.IsPostBack && PageManager.Instance.ExecuteOnReadyWhenPostBack))
            //{
            //    afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}");
            //}
            //afterBuilder.Append("\r\n");

            //#if DEBUG
            //            afterBuilder.Append("window.f_render_end_time = new Date();");
            //#endif
            #endregion


            // 需要注册script
            //string contentScript = String.Format("EXTASPNET_READY=function(){{{0}}};", beforeBuilder.ToString() + script + afterBuilder.ToString());
            //contentScript += "Ext.onReady(EXTASPNET_READY);";//Ext.EventManager.on(window,'onload',function(){EXTASPNET_READY();});";//if(Ext.isIE){}else{Ext.onReady(EXTASPNET_READY);}";
            string contentScript = String.Format("F.load(function(){{{0}}});", beforeBuilder.ToString() + script);
            //#if DEBUG
            //            contentScript += "var x_end_time=new Date();";
            //#endif

            #region RELEASE模式下去除换行符

            if (!GlobalConfig.GetDebugMode())
            {
                contentScript = contentScript.Replace("\r\n", "");
            }

            #endregion

            string checkScript = "if(!F&&!Ext){if(confirm('ERROR: extjs folder is lost, download it now?')){window.location.href='http://fineui.com/bbs/forum.php?mod=viewthread&tid=3218';}}";

            return checkScript + contentScript;
        }
Beispiel #15
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            //return GetShowReference(Message, Title, MessageBoxIcon, OkScript, Target, Icon, IconUrl);

            //if (message == null)
            //{
            //    message = String.Empty;
            //}
            //if (title == null)
            //{
            //    title = String.Empty;
            //}

            string message = "";
            string title = "";
            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }


            string addCSSScript = String.Empty;
            string iconScriptFragment = String.Empty;
            string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl);

            Page page = HttpContext.Current.CurrentHandler as Page;
            if (page != null)
            {
                resolvedIconUrl = page.ResolveUrl(resolvedIconUrl);
            }

            Target target = Target;
            // Icon 或者 IconUrl 不为空
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                string className = String.Format("f-{0}-alert-icon", System.Guid.NewGuid().ToString("N"));

                var addCSSPrefix = String.Empty;
                if (target == Target.Parent)
                {
                    addCSSPrefix = "parent.";
                }
                else if (target == Target.Top)
                {
                    addCSSPrefix = "top.";
                }
                addCSSScript = String.Format("{0}F.addCSS('{1}','{2}');", addCSSPrefix, className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, resolvedIconUrl));

                iconScriptFragment = String.Format("'{0}'", className);
            }
            else
            {
                iconScriptFragment = MessageBoxIconHelper.GetName(MessageBoxIcon);
            }

            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");
            title = title.Replace("\r\n", "\n").Replace("\n", "<br/>");
            string targetScript = "window";
            if (target != Target.Self)
            {
                targetScript = TargetHelper.GetScriptName(target);
            }

            JsObjectBuilder jsob = new JsObjectBuilder();
            if (!String.IsNullOrEmpty(CssClass))
            {
                jsob.AddProperty("cls", CssClass);
            }
            if (!String.IsNullOrEmpty(title))
            {
                jsob.AddProperty("title", title);
            }
            if (!String.IsNullOrEmpty(OkScript))
            {
                jsob.AddProperty("ok", JsHelper.GetFunction(OkScript), true);
            }
            if (!String.IsNullOrEmpty(message))
            {
                jsob.AddProperty("message", JsHelper.EnquoteWithScriptTag(message), true);
            }
            if (!String.IsNullOrEmpty(iconScriptFragment))
            {
                jsob.AddProperty("messageIcon", iconScriptFragment, true);
            }

            return addCSSScript + String.Format("{0}.F.alert({1});", targetScript, jsob);
        }
Beispiel #16
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            string message = "";
            string title = "";
            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }

            JsObjectBuilder jsOB = new JsObjectBuilder();

            if (Target != Target.Self)
            {
                jsOB.AddProperty("target", TargetHelper.GetName(Target));
            }

            if (NotifyIcon != NotifyIcon.Info)
            {
                jsOB.AddProperty("notifyIcon", NotifyIconHelper.GetName(NotifyIcon));
            }

            if (!String.IsNullOrEmpty(title))
            {
                jsOB.AddProperty("title", title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }

            if (!String.IsNullOrEmpty(message))
            {
                jsOB.AddProperty("message", JsHelper.EnquoteWithScriptTag(message.Replace("\r\n", "\n").Replace("\n", "<br/>")), true);
            }

            return String.Format("F.notify({0});", jsOB.ToString());
        }
Beispiel #17
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            // 确保 F_Nodes 在页面第一次加载时都存在于 F_STATE 中,因为客户端需要这个数据来渲染树控件
            // 并且这个代码要放在 base.OnFirstPreRender(); 之前,因为在那里面会生成 F_STATE
            FState.AddModifiedProperty("F_Nodes");

            base.OnFirstPreRender();

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

            #region viewConfig

            JsObjectBuilder viewBuilder = new JsObjectBuilder();

            if (EnableTextSelection)
            {
                viewBuilder.AddProperty("enableTextSelection", true);
            }

            if (viewBuilder.Count > 0)
            {
                OB.AddProperty("viewConfig", viewBuilder);
            }
            
            #endregion

            #region options

            OB.AddProperty("useArrows", EnableArrows);
            OB.AddProperty("lines", EnableLines);

            OB.AddProperty("animate", EnableAnimate);

            OB.AddProperty("singleExpand", EnableSingleExpand);
            

            if (!EnableIcons)
            {
                OB.AddProperty("bodyCls", "x-tree-noicon");
            }


            // 这个为了在客户端生成 PostBack 脚本,比如 __doPostBack('RegionPanel1$TreePanel1','')
            OB.AddProperty("name", UniqueID);

            #endregion

            #region oldcode

            //string hiddenFieldsScript = String.Empty;

            //// 选中的行
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(SelectedNodeHiddenFieldID, SelectedNode == null ? "" : SelectedNode.NodeID);

            //// 展开的行
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(ExpandedNodesHiddenFieldID, StringUtil.GetStringFromStringArray(GetExpandedNodeIDs()));

            //// 选中的行
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(CheckedNodesHiddenFieldID, StringUtil.GetStringFromStringArray(GetCheckedNodeIDs()));


            #endregion

            #region Loader

            string loaderScript = String.Empty;

            JsObjectBuilder loaderBuilder = new JsObjectBuilder();


            JsObjectBuilder listenersBuilder = new JsObjectBuilder();

            string paramStr = String.Format("LazyLoad${0}", "#ID#");
            string postBackScript = GetPostBackEventReference(paramStr);
            postBackScript = postBackScript.Replace("#ID#'", "'+op.id");
            listenersBuilder.AddProperty("beforeload", String.Format("function(store,op){{if(op.action==='read'&&op.id!=='root'){{{0}}}return false;}}", postBackScript), true);

            //listenersBuilder.AddProperty(OptionName.Scope, "box", true);
            loaderBuilder.AddProperty("listeners", listenersBuilder);
            // 必须添加dataUrl,才会引发beforeload事件
            //loaderBuilder.AddProperty("dataUrl", "about:blank");
            //loaderBuilder.AddProperty("preloadChildren", true);
            //loaderBuilder.AddProperty("clearOnLoad", false);

            loaderScript = String.Format("var {0}=Ext.create('Ext.data.TreeStore',{1});", Render_StoreID, loaderBuilder);

            OB.AddProperty("store", Render_StoreID, true);
            #endregion

            #region Listeners

            string beforeclickScript = "if(node.disabled){return false;}";
            //OB.Listeners.AddProperty("beforeitemclick", JsHelper.GetFunction(beforeclickScript, "view", "node", "item", "index"), true);
            AddListener("beforeitemclick", beforeclickScript, "view", "node", "item", "index");


            string singleclickexpandScript = "";
            if (EnableSingleClickExpand)
            {
                //singleclickexpandScript = "if(!node.isLeaf()){if(node.isExpanded()){node.collapse();}else{node.expand();}}";
                singleclickexpandScript = "if(node.isExpandable()&&!node.isLeaf()){if(node.isExpanded()){this.collapseNode(node);}else{this.expandNode(node);}}";
            }

            string itemclickScript = "var args='Command$'+node.getId()+'$'+node.raw.f_commandname+'$'+node.raw.f_commandargument;";
            itemclickScript += GetPostBackEventReference("#Click#").Replace("'#Click#'", "args");
            itemclickScript = String.Format("if(node.raw.f_enableclickevent){{{0}}}", itemclickScript);
            itemclickScript = "if(node.raw.f_clientclick){if(new Function(node.raw.f_clientclick)()===false){return;}}" + itemclickScript;
            //itemclickScript = "if(node.raw.f_clientclick){eval(node.raw.f_clientclick);}" + itemclickScript; // new Function(node.raw.f_clientclick)();
            //OB.Listeners.AddProperty("itemclick", JsHelper.GetFunction(singleclickexpandScript + itemclickScript, "view", "node", "item", "index"), true);
            AddListener("itemclick", singleclickexpandScript + itemclickScript, "view", "node", "item", "index");



            string checkchangeScript = "var args='Check$'+node.getId()+'$'+checked;";
            checkchangeScript += GetPostBackEventReference("#CheckChange#").Replace("'#CheckChange#'", "args");
            checkchangeScript = String.Format("if(node.raw.f_enablecheckevent){{{0}}}", checkchangeScript);
            //OB.Listeners.AddProperty("checkchange", JsHelper.GetFunction(checkchangeScript, "node", "checked"), true);
            AddListener("checkchange", checkchangeScript, "node", "checked");


            string expandScript = "var args='Expand$'+node.getId();";
            expandScript += GetPostBackEventReference("#Expand#").Replace("'#Expand#'", "args");
            expandScript = String.Format("if(node.raw.f_enableexpandevent){{{0}}}", expandScript);
            //OB.Listeners.AddProperty("itemexpand", JsHelper.GetFunction(expandScript, "node"), true);
            AddListener("itemexpand", expandScript, "node");


            string collapseScript = "var args='Collapse$'+node.getId();";
            collapseScript += GetPostBackEventReference("#Collapse#").Replace("'#Collapse#'", "args");
            collapseScript = String.Format("if(node.raw.f_enablecollapseevent){{{0}}}", collapseScript);
            //OB.Listeners.AddProperty("itemcollapse", JsHelper.GetFunction(collapseScript, "node"), true);
            AddListener("itemcollapse", collapseScript, "node");

            #endregion

            #region selectModel

            string selectModelScript = String.Empty;
            if (EnableMultiSelect)
            {
                selectModelScript = "Ext.create('Ext.selection.TreeModel',{mode:'MULTI'})";
            }
            else
            {
                selectModelScript = "Ext.create('Ext.selection.TreeModel',{mode:'SINGLE'})";
            }
            OB.AddProperty("selModel", selectModelScript, true);

            #endregion

            #region old code

            // nodes
            //string nodesScript = Render_NodesId + "=[{'text':'Audi','id':100,'leaf':false,'cls':'folder','children':[{'text':'A3','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]},{'text':'TT','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]}]},{'text':'Cadillac','id':300,'leaf':false,'cls':'folder','children':[{'text':'CTS','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]},{'text':'CTS-V','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]}]}];";
            //string nodesJsArray = GetNodesJsArray2(Nodes).ToString();
            //string nodesScript = String.Format("{0}={1};", Render_NodesID, nodesJsArray);

            #endregion

            #region Root

            //JsObjectBuilder rootBuilder = new JsObjectBuilder();
            ////rootBuilder.AddProperty(OptionName.Id, "root");
            ////rootBuilder.AddProperty(OptionName.Text, "root");
            ////rootBuilder.AddProperty("loaded", false);
            //rootBuilder.AddProperty(OptionName.Children, Render_NodesId, true);

            //string rootNodeScript = String.Format("var {0}=new Ext.tree.AsyncTreeNode({1});", Render_RootId, rootBuilder.ToString());
            //rootNodeScript += "\r\n";


            //OB.AddProperty("root", "new Ext.tree.AsyncTreeNode()", true);
            OB.AddProperty("rootVisible", false);

            #endregion

            #region renderScript

            //string renderScript = String.Empty;
            ////renderScript += "cmp.f_loadData();";
            //if (SelectedNodeIDArray.Length > 0)
            //{
            //    renderScript += "var model=cmp.getSelectionModel();";
            //    foreach (string nodeId in SelectedNodeIDArray)
            //    {
            //        renderScript += String.Format("model.select(cmp.getNodeById('{0}'),null,true);", nodeId);
            //    }
            //}

            ////renderScript = "function(cmp){window.setTimeout(function(){ cmp.f_loadData(); },1000);}";

            //OB.Listeners.AddProperty("render", JsHelper.GetFunction("cmp.f_loadData();", "cmp"), true);
            AddListener("render", "cmp.f_loadData();", "cmp");


            //OB.Listeners.AddProperty("viewready", JsHelper.GetFunction("cmp.f_selectNodes();", "cmp"), true);
            AddListener("viewready", "cmp.f_selectNodes();", "cmp");

            #endregion

            #region AddStartupScript
            //// 展开,折叠,点击,选中CheckBox事件处理函数,
            //// 因为这些函数会被几乎每个节点使用,所以提取出公共的方法来
            //scripts.AppendFormat("{0}=function(node){{F.util.addValueToHiddenField('{1}',node.id);}};", Render_NodeExpandScriptID, ExpandedNodesHiddenFieldID);
            //scripts.AppendFormat("{0}=function(node){{F.util.removeValueFromHiddenField('{1}',node.id);}};", Render_NodeCollapseScriptID, ExpandedNodesHiddenFieldID);
            //scripts.AppendFormat("{0}=function(node,checked){{if(checked){{F.util.addValueToHiddenField('{1}',node.id);}}else{{F.util.removeValueFromHiddenField('{1}',node.id);}}}};", Render_NodeCheckChangeScriptID, CheckedNodesHiddenFieldID);
            //scripts.AppendFormat("{0}=function(node){{Ext.get('{1}').dom.value=node.id;}};", Render_NodeClickScriptID, SelectedNodeHiddenFieldID);

            //scripts.AppendLine(hiddenFieldsScript);

            //OB.AddProperty("store", "Ext.create('Ext.data.TreeStore')", true);


            //StringBuilder sb = new StringBuilder();

            //scripts.AppendLine(loaderScript);
            string startupScript = String.Format("var {0}=Ext.create('Ext.tree.Panel',{1});", XID, OB);

            AddStartupScript(loaderScript + startupScript);

            #endregion
        }
Beispiel #18
0
        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());
        }
Beispiel #19
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region Reset ActiveIndex

            // 重置面板的 Collapsed 属性
            if (ActivePane != null)
            {
                foreach (AccordionPane pane in Panes)
                {
                    pane.Collapsed = true;
                }

                ActivePane.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

            OB.RemoveProperty("layout");

            JsObjectBuilder configBuilder = new JsObjectBuilder();
            configBuilder.AddProperty("animate", false);
            configBuilder.AddProperty("activeOnTop", EnableActiveOnTop);
            configBuilder.AddProperty("fill", EnableFill);
            configBuilder.AddProperty("hideCollapseTool", !ShowCollapseTool);
            configBuilder.AddProperty("type", "accordion");

            //configBuilder.AddProperty("multi", true);

            OB.AddProperty("layout", configBuilder);

            #endregion

            string jsContent = String.Format("var {0}=Ext.create('Ext.panel.Panel',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }
Beispiel #20
0
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            // ����չ����Ҫ���⴦��
            if (this is TemplateField && (this 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}}}\")}});", Grid.Render_GridRowExpanderID, Grid.Render_GridRowExpanderID);

                string jsContent = String.Format("var {0}=new Ext.ux.grid.RowExpander({{tpl:new Ext.Template(\"{{{1}}}\")}});", XID, ColumnID);
                AddStartupScript(jsContent);
            }
            else
            {
                JsObjectBuilder columnBuilder = new JsObjectBuilder();

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

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

                if (Grid.AllowSorting)
                {
                    if (!String.IsNullOrEmpty(SortField))
                    {
                        //// �Զ���JavaScript����
                        //OB.AddProperty("x_serverSortable", true);
                        OB.AddProperty("sortable", true);
                    }
                }

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

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

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

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

            }
        }
Beispiel #21
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        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


            JsObjectBuilder layoutOB = new JsObjectBuilder();
            layoutOB.AddProperty("pack", ToolbarAlignHelper.GetName(ToolbarAlign));

            OB.AddProperty("layout", layoutOB, true);

            OB.AddProperty("xtype", "toolbar");

            OB.AddProperty("dock", ToolbarPositionHelper.GetExtName(Position));

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

            //string jsContent = String.Format("var {0}={1};", XID, OB.GetProperty("items"));
            string jsContent = String.Format("var {0}={1};", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Beispiel #22
0
        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="rowIdsBuilder">行ID集合</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

            //string bodyStyleStr = String.Empty;
            //if (EnableBackgroundColor)
            //{
            //    bodyStyleStr = GlobalConfig.GetDefaultBackgroundColor();
            //}

            //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", "anchor");
                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}=Ext.create('Ext.panel.Panel',{1});", rowId, rowBuilder.ToString());
        }
Beispiel #23
0
        /// <summary>
        /// 取得页面初始化时脚本
        /// </summary>
        /// <param name="script"></param>
        /// <returns></returns>
        private string GetStartupScript(string script)
        {
            #region beforeBuilder

            StringBuilder beforeBuilder = new StringBuilder();

            //beforeBuilder.Append("F.init();");

            // ExtJS2.2的BUG,Ext.onReady会被调用两次(在ExtJS 2.2.1中已经修正)
            // Ext.onReady在extjsv3.1.0中依然有问题,在IE下有时会导致页面空白,不能继续执行,只有在点击Stop按钮或者重新刷新后才行。
            // http://www.extjs.net/forum/showthread.php?t=69437
            // http://www.extjs.com/forum/showthread.php?p=347524#post347524
            // https://extjs.net/forum/showthread.php?t=86948
            //beforeBuilder.Append("if(X.initialized){return;}X.initialized=true;");

            // 空白图片,只在 IE6 和 IE7 下设置(默认为 http://www.sencha.com/s.gif ),其他浏览器下使用 data URL
            //beforeBuilder.AppendFormat("if(Ext.isIE6||Ext.isIE7){{Ext.BLANK_IMAGE_URL='{0}';}}", ResourceHelper.GetWebResourceUrl("FineUI.res.img.s.gif"));

            //beforeBuilder.Append("F.util.init();");

            // form 相关配置
            //beforeBuilder.Append("var fieldPro=Ext.form.Base.prototype;");
            //beforeBuilder.AppendFormat("fieldPro.msgTarget='{0}';", MsgTargetHelper.GetName(PageManager.Instance.FormMessageTarget));
            //beforeBuilder.AppendFormat("fieldPro.labelWidth={0};", PageManager.Instance.FormLabelWidth.Value);
            //beforeBuilder.AppendFormat("fieldPro.labelSeparator='{0}';", PageManager.Instance.FormLabelSeparator);
            //beforeBuilder.AppendFormat("F.util.init('{0}',{1},'{2}','{3}',{4},'{5}',{6},'{7}',{8});",
            //    MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget),
            //    PageManager.Instance.FormLabelWidth.Value,
            //    PageManager.Instance.FormLabelSeparator,
            //    //PageManager.Instance.EnableBigFont.ToString().ToLower(),
            //    Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()), //String.Format("{0}/res/images/s.gif", GlobalConfig.GetExtjsBasePath())), //ResourceHelper.GetWebResourceUrlResAxd("FineUI.res.img.s.gif&v=1"),
            //    //PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(),
            //    PageManager.Instance.EnableAjaxLoading.ToString().ToLower(),
            //    AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType),
            //    PageManager.Instance.EnableAjax.ToString().ToLower(),
            //    ThemeHelper.GetName(PageManager.Instance.Theme),
            //    PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower()
            //    );


            //beforeBuilder.AppendFormat("F.util.init('{0}',{1},'{2}','{3}',{4},'{5}',{6},'{7}',{8});",
            //    MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget),
            //    PageManager.Instance.FormLabelWidth.Value,
            //    PageManager.Instance.FormLabelSeparator,
            //    //PageManager.Instance.EnableBigFont.ToString().ToLower(),
            //    Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()), //String.Format("{0}/res/images/s.gif", GlobalConfig.GetExtjsBasePath())), //ResourceHelper.GetWebResourceUrlResAxd("FineUI.res.img.s.gif&v=1"),
            //    //PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(),
            //    PageManager.Instance.EnableAjaxLoading.ToString().ToLower(),
            //    AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType),
            //    PageManager.Instance.EnableAjax.ToString().ToLower(),
            //    ThemeHelper.GetName(PageManager.Instance.Theme),
            //    PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower()
            //    );

            JsObjectBuilder initObj = new JsObjectBuilder();

            if (PageManager.Instance.FormMessageTarget != ConfigPropertyValue.FORM_MESSAGETARGET_DEFAULT)
            {
                initObj.AddProperty("msgTarget", MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget));
            }

            if (PageManager.Instance.FormLabelWidth != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT)
            {
                initObj.AddProperty("labelWidth", PageManager.Instance.FormLabelWidth.Value);
            }

            if (PageManager.Instance.FormLabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT)
            {
                initObj.AddProperty("labelSeparator", PageManager.Instance.FormLabelSeparator);
            }

            //initObj.AddProperty("blankImageUrl", Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()));

            if (PageManager.Instance.EnableAjaxLoading != ConfigPropertyValue.ENABLE_AJAX_LOADING_DEFAULT)
            {
                initObj.AddProperty("enableAjaxLoading", PageManager.Instance.EnableAjaxLoading.ToString().ToLower());
            }

            if (PageManager.Instance.AjaxLoadingType != ConfigPropertyValue.AJAX_LOADING_TYPE_DEFAULT)
            {
                initObj.AddProperty("ajaxLoadingType", AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType));
            }

            if (PageManager.Instance.EnableAjax != ConfigPropertyValue.ENABLE_AJAX_DEFAULT)
            {
                initObj.AddProperty("enableAjax", PageManager.Instance.EnableAjax.ToString().ToLower());
            }

            if (PageManager.Instance.Theme != Theme.Neptune)
            {
                initObj.AddProperty("theme", ThemeHelper.GetName(PageManager.Instance.Theme));
            }

            if (PageManager.Instance.Language != ConfigPropertyValue.LANGUAGE_DEFAULT)
            {
                initObj.AddProperty("language", LanguageHelper.GetName(PageManager.Instance.Language));
            }



            if (PageManager.Instance.EnableFormChangeConfirm)
            {
                initObj.AddProperty("formChangeConfirm", PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower());
            }

            if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT)
            {
                initObj.AddProperty("ajaxTimeout", PageManager.Instance.AjaxTimeout);
            }

            initObj.AddProperty("_version", GlobalConfig.ProductVersion);

            beforeBuilder.AppendFormat("F.init({0});", initObj);

            //if (PageManager.Instance.BeforeAjaxPostBackScript != String.Empty)
            //{
            //    beforeBuilder.AppendFormat("F.util.beforeAjaxPostBackScript=function(){{{0}}};", PageManager.Instance.BeforeAjaxPostBackScript);
            //}

            //beforeBuilder.Append("F.ajax.hookPostBack();");

            //if (PageManager.Instance.EnableAjax)
            //{
            //    if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT)
            //    {
            //        beforeBuilder.AppendFormat("Ext.Ajax.timeout={0};", PageManager.Instance.AjaxTimeout * 1000);
            //    }
            //}

            //if (PageManager.Instance.EnableBigFont)
            //{
            //    beforeBuilder.Append("Ext.getBody().addCls('bigfont');");
            //}


            // WindowGroup
            //beforeBuilder.AppendFormat("{0}=new Ext.WindowGroup();{0}.zseed=6000;", WINDOW_DEFAULT_GROUP_ID);

            //// CookieProvider
            //beforeBuilder.AppendFormat("{0}=new Ext.state.CookieProvider();", COOKIE_PROVIDER_ID);

            //// HiddenFields
            //beforeBuilder.AppendFormat("{0}=[];", HIDDEN_FIELDS_ID);

            // 保存页面中可输入的表单字段状态是否发生变化的隐藏字段
            //innderBuilder.AppendFormat("var sn=document.createElement('input');sn.type='hidden';sn.value='false';sn.id=sn.name='{0}';Ext.getBody().query('form')[0].appendChild(sn);", PAGE_STATE_CHANGED_ID);
            //innderBuilder.AppendFormat("Ext.DomHelper.append(document.forms[0],{{tag:'input',type:'hidden',value:'false',id:'{0}',name:'{0}'}});", PAGE_STATE_CHANGED_ID);
            //beforeBuilder.AppendFormat("F.util.setHiddenFieldValue('{0}','false');", PAGE_STATE_CHANGED_ID);

            // 5.预加载图片
            //beforeBuilder.AppendFormat("{0}=[];", PRELOAD_IMAGES_ID);
            //beforeBuilder.AppendFormat("{0}.push('{1}');", PRELOAD_IMAGES_ID, ResourceHelper.GetWebResourceUrl(Page, "FineUI.res.img.default.form.error-tip-corners.gif"));
            //beforeBuilder.AppendFormat("box_preloadImages({0});", PRELOAD_IMAGES_ID);

            #endregion

            #region afterBuilder

            //StringBuilder afterBuilder = new StringBuilder();

            //afterBuilder.Append("\r\n");

            // 注册隐藏字段
            //string hiddenFieldScript = "var itemNode=Ext.get(item[0]);if(itemNode==null){Ext.DomHelper.append(document.forms[0],{tag:'input',type:'hidden',value:item[1],id:item[0],name:item[0]});}else{itemNode.dom.value=item[1];}";
            //afterBuilder.AppendFormat("Ext.each({0},function(item){{{1}}},box);", HIDDEN_FIELDS_ID, hiddenFieldScript);
            //afterBuilder.Append("box_alertDEBUG();");

            //afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}");
            //afterBuilder.Append("F.util.triggerReady();");
            //// 如果是回发并且允许回发注册onReady脚本
            //if (!Page.IsPostBack || (Page.IsPostBack && PageManager.Instance.ExecuteOnReadyWhenPostBack))
            //{
            //    afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}");
            //}
            //afterBuilder.Append("\r\n");

            //#if DEBUG
            //            afterBuilder.Append("window.f_render_end_time = new Date();");
            //#endif
            #endregion


            // 需要注册script
            //string contentScript = String.Format("EXTASPNET_READY=function(){{{0}}};", beforeBuilder.ToString() + script + afterBuilder.ToString());
            //contentScript += "Ext.onReady(EXTASPNET_READY);";//Ext.EventManager.on(window,'onload',function(){EXTASPNET_READY();});";//if(Ext.isIE){}else{Ext.onReady(EXTASPNET_READY);}";
            string contentScript = String.Format("F.load(function(){{{0}}});", beforeBuilder.ToString() + script);
            //#if DEBUG
            //            contentScript += "var x_end_time=new Date();";
            //#endif

            #region RELEASE模式下去除换行符

            if (!GlobalConfig.GetDebugMode())
            {
                contentScript = contentScript.Replace("\r\n", "");
            }

            #endregion

            string checkScript = "if(!F&&!Ext){if(confirm('ERROR: extjs folder is lost, download it now?')){window.location.href='http://fineui.com/bbs/forum.php?mod=viewthread&tid=3218';}}";

            return(checkScript + contentScript);
        }
Beispiel #24
0
        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)
            {
                JsObjectBuilder rowNumberBuilder = new JsObjectBuilder();
                if (RowNumberWidth != Unit.Empty)
                {
                    rowNumberBuilder.AddProperty("width", RowNumberWidth.Value);
                }
                if (AllowPaging)
                {
                    rowNumberBuilder.AddProperty("x_paging", Render_PagingID, true);
                }
                if (EnableRowNumberPaging)
                {
                    rowNumberBuilder.AddProperty("x_paging_enabled", EnableRowNumberPaging);
                }

                columnsBuilder.AddProperty(String.Format("new Ext.grid.RowNumberer({0})", rowNumberBuilder.ToString()), true);
            }
            // 如果启用CheckBox,则放在第二列
            // 如果启用单元格编辑,则EnableCheckBoxSelect属性失效
            if (EnableCheckBoxSelect && !AllowCellEditing)
            {
                columnsBuilder.AddProperty(selectModelID, true);
            }

            string groupColumnScript = GetGroupColumnScript();

            string expanderXID = String.Empty;
            foreach (GridColumn column in AllColumns)
            {
                if (column is TemplateField && (column as TemplateField).RenderAsRowExpander)
                {
                    expanderXID = column.XID;
                }

                columnsBuilder.AddProperty(column.XID, true);

            }

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

            if (!String.IsNullOrEmpty(expanderXID))
            {
                pluginBuilder.AddProperty(expanderXID, 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 groupColumnScript + columnModelScript;
        }
Beispiel #25
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            // 确保 X_Items 和 SelectedValue 在页面第一次加载时都存在于x_state中
            XState.AddModifiedProperty("X_Items");
            XState.AddModifiedProperty("SelectedValue");

            base.OnFirstPreRender();

            #region examples

            //var nextStepList = [
            //    ['审核', '1'],
            //    ['不审核', '2']
            //];
            //var nextStepStore = new Ext.data.SimpleStore({
            //    fields: ['text', 'value'],
            //    data: nextStepList
            //});
            //{
            //    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%'
            //}

            #endregion

            #region Properties

            if (EnableEdit)
            {
                OB.AddProperty("editable", true);
            }
            else
            {
                OB.AddProperty("editable", false);
            }

            if (ForceSelection)
            {
                OB.AddProperty("forceSelection", true);
            }
            else
            {
                OB.AddProperty("forceSelection", false);
            }

            if (Resizable)
            {
                OB.AddProperty("resizable", true);
            }

            OB.AddProperty("hiddenName", UniqueID);

            //OB.AddProperty("store", "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})", true);
            JsObjectBuilder storeBuilder = new JsObjectBuilder();
            storeBuilder.AddProperty("fields", "['value','text','enabled','prefix']", true);
            storeBuilder.AddProperty("data", String.Format("X.simulateTree.transform({0}.X_Items)", GetXStateScriptID()), true);
            OB.AddProperty("store", String.Format("new Ext.data.ArrayStore({0})", storeBuilder), true);

            OB.AddProperty("value", String.Format("{0}.SelectedValue", GetXStateScriptID()), true);



            OB.AddProperty("tpl", "X.util.ddlTPL", true);

            OB.AddProperty("mode", "local");
            OB.AddProperty("triggerAction", "all");
//            mode: "local",
//        triggerAction: "all",


            #region old code
            //OB.AddProperty("mode", "local");
            //// 点击下拉按钮时显示全部内容
            //OB.AddProperty("triggerAction", "all");
            //// 必须选中一个值,不能自己输入内容
            //OB.AddProperty("forceSelection", true);
            //// 此下拉列表控件不可以编辑
            //OB.AddProperty("editable", false);

            //OB.AddProperty(OptionName.Title, "Title");
            //if (TypeAhead) OB.AddProperty(OptionName.TypeAhead, true);
            //OB.AddProperty(OptionName.SelectOnFocus, true);

            //// SelectedValue可以为空
            //if (!String.IsNullOrEmpty(SelectedValue))
            //{
            //    OB.AddProperty("value", SelectedValue);
            //}
            #endregion

            #endregion

            #region old code

            //string hiddenFieldsScript = String.Empty;
            //if (AutoPostBack)
            //{
            //    hiddenFieldsScript += GetSetHiddenFieldValueScript(LastSelectedValueHiddenID, SelectedValue);
            //}

            //string disableSelectRowIndexsString = GetDisableSelectRowIndexsString();
            //string disableSelectRowIndexsScript = GetSetHiddenFieldValueScript(DisableRowIndexsHiddenID, disableSelectRowIndexsString);

            //// TODO:
            //// 这个要放在加载数据的前面,因为加载数据时需要渲染UI,渲染UI时需要用到这个隐藏字段的值
            //if (AjaxPropertyChanged("DisableSelectRowIndexsString", disableSelectRowIndexsString))
            //{
            //    AddAjaxPropertyChangedScript(disableSelectRowIndexsScript);
            //}


            // 不管是不是disableSelectFields.Count > 0,都要执行下面的语句,因为可能页面加载时为0,在Ajax后不为零
            //if (disableSelectFields.Count > 0)
            //OB.AddProperty(OptionName.Tpl, String.Format("'<tpl for=\".\"><div class=\"x-combo-list-item {{[X.util.isHiddenFieldContains(\"{0}\",xindex-1) ? \"box-combo-list-item-disable-select\" : \"\"]}}\">{{text}}</div></tpl>'", DisableSelectRowIndexsHiddenID), true);
            //var tplStr = "'<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>'";
            //var tplStr = "new Ext.XTemplate('<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>')";

            //var tplStr = "<tpl for=\".\"><div class=\"x-combo-list-item <tpl if=\"!enabled\">x-combo-list-item-disable</tpl>\">{prefix}{text}</div></tpl>";
            //OB.AddProperty("tpl", tplStr);
            //OB.AddProperty("tpl", tplStr.Replace("#DisableRowIndexsHiddenID#", DisableRowIndexsHiddenID), true);


            //string setSimulateTreeTextFunctionScript = String.Empty;
            //string setSimulateTreeTextScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    string setSimulateTextScript = String.Format("var text=Ext.get('{0}').dom.value;if(text.lastIndexOf('<img')>=0){{Ext.get('{0}').dom.value=X.util.stripHtmlTags(text);}}", ClientID);
            //    setSimulateTreeTextFunctionScript = String.Format("{0}_setSimulateText=function(){{{1}}};", ClientJavascriptID, setSimulateTextScript);

            //    // 加载完毕后,显示选中的值
            //    //AddAbsoluteStartupScript(String.Format("{0}_setSimulateText();", ClientJavascriptID));
            //    // 下拉列表加载完毕后,立即去掉前面图片的HTML标签
            //    string renderScript = JsHelper.GetDeferScript(String.Format("{0}_setSimulateText();", ClientJavascriptID), 20); // "(function(){" + String.Format("{0}_setSimulateText();", ClientJavascriptID) + "}).defer(20);";
            //    OB.Listeners.AddProperty(OptionName.EVENT_RENDER, "function(component){" + renderScript + "}", true);
            //}


            //string simulateTreeAllScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    // 在选中一项后,立即去掉前面图片的HTML标签
            //    simulateTreeAllScript += "\r\n";
            //    //string simulateTreeScript = String.Format("function(ddl,record,index){{var text=record.data.text;var startDivIndex=text.lastIndexOf('</div>');text=text.substr(startDivIndex+6);Ext.get('{0}').dom.value=text;}}", ClientID);
            //    string simulateTreeScript = String.Format("function(ddl,record,index){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeScript = String.Format("{0}.on('{1}',{2},box,{{delay:0}});", ClientJavascriptID, OptionName.Select, simulateTreeScript);
            //    //AddAbsoluteStartupScript( simulateTreeScript);
            //    simulateTreeAllScript += simulateTreeScript;

            //    simulateTreeAllScript += "\r\n";
            //    string simulateTreeBlurScript = String.Format("function(ddl){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeBlurScript = String.Format("{0}.on('{1}',{2},box,{{delay:10}});", ClientJavascriptID, OptionName.Blur, simulateTreeBlurScript);
            //    //AddAbsoluteStartupScript( simulateTreeBlurScript);
            //    simulateTreeAllScript += simulateTreeBlurScript;
            //}



            // These are default values, which are assignment in extender.js.
            //OB.AddProperty("displayField", "text");
            //OB.AddProperty("valueField", "value");
            //OB.AddProperty("store", "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})", true);

            //string dataScript = String.Empty;
            //string fields = "['value','text','enabled','prefix']";
            //string storeScript = "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})";//", fields, GetDataArrayString()); // GetDataArrayString()

            //OB.AddProperty(OptionName.Store, String.Format("new Ext.data.ArrayStore({{fields:['value','text'],data:{0}}})", dataArrayString), true);
            //OB.AddProperty("store", String.Format("{0}_data", XID), true);
            //string dataScript = String.Format("{0}_data=new Ext.data.ArrayStore({{fields:['value','text'],data:{1}}});", ClientJavascriptID, dataArrayString);
            //sb.AppendFormat("this.{0}_store=new Ext.data.SimpleStore({{fields:['text', 'value'],data:this.{0}_data}});", ClientJavascriptID);
            #endregion

            #region AutoPostBack

            StringBuilder beforeselectSB = new StringBuilder();
            // 是否能选中一项(如果此项不能选中,则点击没用)
            //beforeselectSB.AppendFormat("if(X.util.isHiddenFieldContains('{0}',index)){{return false;}}", DisableRowIndexsHiddenID);
            beforeselectSB.Append("if(!record.data.enabled){return false;}");

            if (AutoPostBack)
            {
                beforeselectSB.Append("cmp.x_tmp_lastvalue=cmp.getValue();");

                string selectScript = "if(cmp.x_tmp_lastvalue!==cmp.getValue()){" + GetPostBackEventReference() + "}";
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(selectScript, "cmp"), true);
            }

            OB.Listeners.AddProperty("beforeselect", JsHelper.GetFunction(beforeselectSB.ToString(), "cmp", "record", "index"), true);

            #region old code
            //if (AutoPostBack)
            //{
            //    // Note: we can't use change event, because it get triggered when the combox lost focus, which is not in time.
            //    // Beforeselect - If current select item is not changed, don't PostBack.
            //    string beforeselectScript = String.Format("function(ddl,record,index){{Ext.get('{0}').dom.value=Ext.get('{1}').dom.value;}}", LastSelectedValueHiddenID, SelectedValueHiddenID);
            //    beforeselectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "beforeselect", beforeselectScript);
            //    //AddAbsoluteStartupScript( beforeselectScript);
            //    autoPostBackScript += beforeselectScript;

            //    // Select
            //    string selectScript = String.Format("function(ddl,record,index){{if(record.data.value!=Ext.get('{0}').dom.value){{{1}}}}}", LastSelectedValueHiddenID, GetPostBackEventReference());
            //    selectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "select", selectScript);
            //    //AddAbsoluteStartupScript( selectScript);
            //    autoPostBackScript += selectScript;


            //    //OB.Listeners.RemoveProperty(OptionName.Change);
            //    //OB.Listeners.AddProperty(OptionName.Change, String.Format("function(ddl,newValue,oldValue){{box_pageStateChange();alert(newValue+':'+oldValue);}}"), true);
            //}
            #endregion

            #endregion

            #region Listeners - render

            //string renderScript = "cmp.x_loadData();cmp.x_setValue();";

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

            #endregion

            #region AddStartupScript

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

            AddStartupScript(contentScript);

            #region old code
            //List<string> totalModifiedProperties = XState.GetTotalModifiedProperties();
            //StringBuilder loadDataSB = new StringBuilder();
            //if (totalModifiedProperties.Contains("X_Items"))
            //{
            //    loadDataSB.AppendFormat("{0}.x_loadData();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.store.loadData({1});", XID, X_Items.ToString());
            //}

            //if (totalModifiedProperties.Contains("SelectedValue"))
            //{
            //    loadDataSB.AppendFormat("{0}.x_setValue();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.x_setValue({1});", XID, JsHelper.Enquote(SelectedValue));
            //}
            #endregion

            #endregion
        }
Beispiel #26
0
        private string GetGridSelectModel()
        {
            JsObjectBuilder selectOB = new JsObjectBuilder();

            if (AllowCellEditing)
            {

                return String.Format("var {0}=new Ext.grid.CellSelectionModel({1});", Render_SelectModelID, selectOB);
            }
            else
            {
                selectOB.AddProperty("singleSelect", !EnableMultiSelect);

                if (EnableCheckBoxSelect && CheckBoxSelectOnly)
                {
                    selectOB.AddProperty("checkOnly", true);
                }

                //selectOB.AddProperty("listeners", "{beforerowselect:function(){return false;}}", true);

                if (EnableRowSelectEvent)
                {
                    string validateScript = "var args='RowSelect$'+rowIndex;";
                    validateScript += GetPostBackEventReference("#RowSelect#").Replace("'#RowSelect#'", "args");

                    string rowSelectScript = String.Format("function(model,rowIndex){{{0}}}", validateScript);

                    selectOB.AddProperty("listeners", "{rowselect:" + rowSelectScript + "}", true);
                }

                if (EnableCheckBoxSelect)
                {
                    return String.Format("var {0}=new Ext.grid.CheckboxSelectionModel({1});", Render_SelectModelID, selectOB);
                }
                else
                {
                    return String.Format("var {0}=new Ext.grid.RowSelectionModel({1});", Render_SelectModelID, selectOB);
                }
            }
        }
Beispiel #27
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            //return GetShowReference(Message, Title, MessageBoxIcon, OkScript, Target, Icon, IconUrl);

            //if (message == null)
            //{
            //    message = String.Empty;
            //}
            //if (title == null)
            //{
            //    title = String.Empty;
            //}

            string message = "";
            string title   = "";

            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }


            string addCSSScript       = String.Empty;
            string iconScriptFragment = String.Empty;
            string resolvedIconUrl    = IconHelper.GetResolvedIconUrl(Icon, IconUrl);

            Page page = HttpContext.Current.CurrentHandler as Page;

            if (page != null)
            {
                resolvedIconUrl = page.ResolveUrl(resolvedIconUrl);
            }

            Target target = Target;

            // Icon 或者 IconUrl 不为空
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                string className = String.Format("f-{0}-alert-icon", System.Guid.NewGuid().ToString("N"));

                var addCSSPrefix = String.Empty;
                if (target == Target.Parent)
                {
                    addCSSPrefix = "parent.";
                }
                else if (target == Target.Top)
                {
                    addCSSPrefix = "top.";
                }
                addCSSScript = String.Format("{0}F.addCSS('{1}','{2}');", addCSSPrefix, className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, resolvedIconUrl));

                iconScriptFragment = String.Format("'{0}'", className);
            }
            else
            {
                iconScriptFragment = MessageBoxIconHelper.GetName(MessageBoxIcon);
            }

            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");
            title   = title.Replace("\r\n", "\n").Replace("\n", "<br/>");
            string targetScript = "window";

            if (target != Target.Self)
            {
                targetScript = TargetHelper.GetScriptName(target);
            }

            JsObjectBuilder jsob = new JsObjectBuilder();

            if (!String.IsNullOrEmpty(CssClass))
            {
                jsob.AddProperty("cls", CssClass);
            }
            if (!String.IsNullOrEmpty(title))
            {
                jsob.AddProperty("title", title);
            }
            if (!String.IsNullOrEmpty(OkScript))
            {
                jsob.AddProperty("ok", JsHelper.GetFunction(OkScript), true);
            }
            if (!String.IsNullOrEmpty(message))
            {
                jsob.AddProperty("message", JsHelper.EnquoteWithScriptTag(message), true);
            }
            if (!String.IsNullOrEmpty(iconScriptFragment))
            {
                jsob.AddProperty("messageIcon", iconScriptFragment, true);
            }

            return(addCSSScript + String.Format("{0}.F.alert({1});", targetScript, jsob));
        }
Beispiel #28
0
        private JsObjectBuilder GetPagingBuilder()
        {
            JsObjectBuilder pagingBuilder = new JsObjectBuilder();
            pagingBuilder.AddProperty("pageSize", PageSize);
            pagingBuilder.AddProperty("pageIndex", PageIndex);
            pagingBuilder.AddProperty("recordCount", RecordCount);
            pagingBuilder.AddProperty("pageCount", PageCount);

            int startRowIndex, endRowIndex;
            ResolveStartEndRowIndex(out startRowIndex, out endRowIndex);
            if (IsDatabasePaging)
            {
                pagingBuilder.AddProperty("x_databasePaging", true);
            }
            else
            {
                pagingBuilder.AddProperty("x_startRowIndex", startRowIndex);
                pagingBuilder.AddProperty("x_endRowIndex", endRowIndex);
            }

            return pagingBuilder;
        }
Beispiel #29
0
        //public override string GetFieldType()
        //{
        //    return "string";
        //}

        #endregion

        #region OnFirstPreRender

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

            if (this is TemplateField && (this as TemplateField).RenderAsRowExpander)
            {
                JsObjectBuilder rowExpanderBuilder = new JsObjectBuilder();
                rowExpanderBuilder.AddProperty("rowBodyTpl", String.Format("Ext.create('Ext.XTemplate','{{{0}}}')", ColumnID), true);
                rowExpanderBuilder.AddProperty("pluginId", String.Format("{0}_rowexpander", Grid.ClientID));

                if (!ExpandOnDoubleClick)
                {
                    rowExpanderBuilder.AddProperty("expandOnDblClick", false);
                }

                if (!ExpandOnEnter)
                {
                    rowExpanderBuilder.AddProperty("expandOnEnter", false);
                }

                if (ExpandToSelectRow)
                {
                    rowExpanderBuilder.AddProperty("selectRowOnExpand", true);
                }


                string jsContent = String.Format("var {0}=Ext.create('Ext.grid.plugin.RowExpander',{1});", XID, rowExpanderBuilder);
                AddGridColumnScript(jsContent);
                
            }
            else
            {
                string jsContent = String.Format("var {0}={1};", XID, OB.ToString());
                AddGridColumnScript(jsContent);
                
            }
        }
Beispiel #30
0
        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="rowIdsBuilder">行ID集合</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


            //string bodyStyleStr = String.Empty;
            //if (EnableBackgroundColor)
            //{
            //    bodyStyleStr = GlobalConfig.GetDefaultBackgroundColor();
            //}

            //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", "anchor");
                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}=Ext.create('Ext.panel.Panel',{1});", rowId, rowBuilder.ToString()));
        }
Beispiel #31
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            // 确保 F_Items 和 SelectedValue 在页面第一次加载时都存在于f_state中
            FState.AddModifiedProperty("F_Items");
            FState.AddModifiedProperty("SelectedValue");

            base.OnFirstPreRender();

            #region examples

            //var nextStepList = [
            //    ['审核', '1'],
            //    ['不审核', '2']
            //];
            //var nextStepStore = new Ext.data.SimpleStore({
            //    fields: ['text', 'value'],
            //    data: nextStepList
            //});
            //{
            //    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%'
            //}

            #endregion

            #region Properties

            if (EnableEdit)
            {
                OB.AddProperty("editable", true);
            }
            else
            {
                OB.AddProperty("editable", false);
            }

            if (ForceSelection)
            {
                OB.AddProperty("forceSelection", true);
            }
            else
            {
                OB.AddProperty("forceSelection", false);
            }

            //if (Resizable)
            //{
            //    OB.AddProperty("resizable", true);
            //}

            OB.AddProperty("hiddenName", SelectedValueHiddenFieldID);

            JsObjectBuilder storeBuilder = new JsObjectBuilder();
            storeBuilder.AddProperty("fields", "['value','text','enabled','prefix']", true);
            storeBuilder.AddProperty("data", String.Format("F.simulateTree.transform({0}.F_Items)", GetFStateScriptID()), true);
            OB.AddProperty("store", String.Format("Ext.create('Ext.data.ArrayStore',{0})", storeBuilder), true);

            OB.AddProperty("value", String.Format("{0}.SelectedValue", GetFStateScriptID()), true);

            OB.AddProperty("tpl", "F.util.ddlTPL", true);

            OB.AddProperty("queryMode", "local");
            OB.AddProperty("triggerAction", "all");

            #region old code
            //OB.AddProperty("mode", "local");
            //// 点击下拉按钮时显示全部内容
            //OB.AddProperty("triggerAction", "all");
            //// 必须选中一个值,不能自己输入内容
            //OB.AddProperty("forceSelection", true);
            //// 此下拉列表控件不可以编辑
            //OB.AddProperty("editable", false);

            //OB.AddProperty(OptionName.Title, "Title");
            //if (TypeAhead) OB.AddProperty(OptionName.TypeAhead, true);
            //OB.AddProperty(OptionName.SelectOnFocus, true);

            //// SelectedValue可以为空
            //if (!String.IsNullOrEmpty(SelectedValue))
            //{
            //    OB.AddProperty("value", SelectedValue);
            //}
            #endregion

            #endregion

            #region old code

            //string hiddenFieldsScript = String.Empty;
            //if (AutoPostBack)
            //{
            //    hiddenFieldsScript += GetSetHiddenFieldValueScript(LastSelectedValueHiddenID, SelectedValue);
            //}

            //string disableSelectRowIndexsString = GetDisableSelectRowIndexsString();
            //string disableSelectRowIndexsScript = GetSetHiddenFieldValueScript(DisableRowIndexsHiddenID, disableSelectRowIndexsString);

            //// TODO:
            //// 这个要放在加载数据的前面,因为加载数据时需要渲染UI,渲染UI时需要用到这个隐藏字段的值
            //if (AjaxPropertyChanged("DisableSelectRowIndexsString", disableSelectRowIndexsString))
            //{
            //    AddAjaxPropertyChangedScript(disableSelectRowIndexsScript);
            //}

            // 不管是不是disableSelectFields.Count > 0,都要执行下面的语句,因为可能页面加载时为0,在Ajax后不为零
            //if (disableSelectFields.Count > 0)
            //OB.AddProperty(OptionName.Tpl, String.Format("'<tpl for=\".\"><div class=\"x-combo-list-item {{[F.util.isHiddenFieldContains(\"{0}\",xindex-1) ? \"f-combo-list-item-disable-select\" : \"\"]}}\">{{text}}</div></tpl>'", DisableSelectRowIndexsHiddenID), true);
            //var tplStr = "'<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>'";
            //var tplStr = "new Ext.XTemplate('<tpl for=\".\"><div class=\"x-combo-list-item\">{text}</div></tpl>')";

            //var tplStr = "<tpl for=\".\"><div class=\"x-combo-list-item <tpl if=\"!enabled\">x-combo-list-item-disable</tpl>\">{prefix}{text}</div></tpl>";
            //OB.AddProperty("tpl", tplStr);
            //OB.AddProperty("tpl", tplStr.Replace("#DisableRowIndexsHiddenID#", DisableRowIndexsHiddenID), true);

            //string setSimulateTreeTextFunctionScript = String.Empty;
            //string setSimulateTreeTextScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    string setSimulateTextScript = String.Format("var text=Ext.get('{0}').dom.value;if(text.lastIndexOf('<img')>=0){{Ext.get('{0}').dom.value=F.util.stripHtmlTags(text);}}", ClientID);
            //    setSimulateTreeTextFunctionScript = String.Format("{0}_setSimulateText=function(){{{1}}};", ClientJavascriptID, setSimulateTextScript);

            //    // 加载完毕后,显示选中的值
            //    //AddAbsoluteStartupScript(String.Format("{0}_setSimulateText();", ClientJavascriptID));
            //    // 下拉列表加载完毕后,立即去掉前面图片的HTML标签
            //    string renderScript = JsHelper.GetDeferScript(String.Format("{0}_setSimulateText();", ClientJavascriptID), 20); // "(function(){" + String.Format("{0}_setSimulateText();", ClientJavascriptID) + "}).defer(20);";
            //    OB.Listeners.AddProperty(OptionName.EVENT_RENDER, "function(component){" + renderScript + "}", true);
            //}

            //string simulateTreeAllScript = String.Empty;
            //if (EnableSimulateTree)
            //{
            //    // 在选中一项后,立即去掉前面图片的HTML标签
            //    simulateTreeAllScript += "\r\n";
            //    //string simulateTreeScript = String.Format("function(ddl,record,index){{var text=record.data.text;var startDivIndex=text.lastIndexOf('</div>');text=text.substr(startDivIndex+6);Ext.get('{0}').dom.value=text;}}", ClientID);
            //    string simulateTreeScript = String.Format("function(ddl,record,index){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeScript = String.Format("{0}.on('{1}',{2},box,{{delay:0}});", ClientJavascriptID, OptionName.Select, simulateTreeScript);
            //    //AddAbsoluteStartupScript( simulateTreeScript);
            //    simulateTreeAllScript += simulateTreeScript;

            //    simulateTreeAllScript += "\r\n";
            //    string simulateTreeBlurScript = String.Format("function(ddl){{X.{0}_setSimulateText();}}", ClientJavascriptID);
            //    simulateTreeBlurScript = String.Format("{0}.on('{1}',{2},box,{{delay:10}});", ClientJavascriptID, OptionName.Blur, simulateTreeBlurScript);
            //    //AddAbsoluteStartupScript( simulateTreeBlurScript);
            //    simulateTreeAllScript += simulateTreeBlurScript;
            //}

            // These are default values, which are assignment in extender.js.
            //OB.AddProperty("displayField", "text");
            //OB.AddProperty("valueField", "value");
            //OB.AddProperty("store", "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})", true);

            //string dataScript = String.Empty;
            //string fields = "['value','text','enabled','prefix']";
            //string storeScript = "new Ext.data.ArrayStore({fields:['value','text','enabled','prefix']})";//", fields, GetDataArrayString()); // GetDataArrayString()

            //OB.AddProperty(OptionName.Store, String.Format("new Ext.data.ArrayStore({{fields:['value','text'],data:{0}}})", dataArrayString), true);
            //OB.AddProperty("store", String.Format("{0}_data", XID), true);
            //string dataScript = String.Format("{0}_data=new Ext.data.ArrayStore({{fields:['value','text'],data:{1}}});", ClientJavascriptID, dataArrayString);
            //sb.AppendFormat("this.{0}_store=new Ext.data.SimpleStore({{fields:['text', 'value'],data:this.{0}_data}});", ClientJavascriptID);
            #endregion

            #region AutoPostBack

            StringBuilder beforeselectSB = new StringBuilder();
            // 是否能选中一项(如果此项不能选中,则点击没用)
            //beforeselectSB.AppendFormat("if(F.util.isHiddenFieldContains('{0}',index)){{return false;}}", DisableRowIndexsHiddenID);
            beforeselectSB.Append("if(!record.data.enabled){return false;}");

            if (AutoPostBack)
            {
                beforeselectSB.Append("cmp.f_tmp_lastvalue=cmp.getValue();");

                string selectScript = "if(cmp.f_tmp_lastvalue!==cmp.getValue()){" + GetPostBackEventReference() + "}";
                OB.Listeners.AddProperty("select", JsHelper.GetFunction(selectScript, "cmp"), true);
            }

            OB.Listeners.AddProperty("beforeselect", JsHelper.GetFunction(beforeselectSB.ToString(), "cmp", "record", "index"), true);

            #region old code
            //if (AutoPostBack)
            //{
            //    // Note: we can't use change event, because it get triggered when the combox lost focus, which is not in time.
            //    // Beforeselect - If current select item is not changed, don't PostBack.
            //    string beforeselectScript = String.Format("function(ddl,record,index){{Ext.get('{0}').dom.value=Ext.get('{1}').dom.value;}}", LastSelectedValueHiddenID, SelectedValueHiddenID);
            //    beforeselectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "beforeselect", beforeselectScript);
            //    //AddAbsoluteStartupScript( beforeselectScript);
            //    autoPostBackScript += beforeselectScript;

            //    // Select
            //    string selectScript = String.Format("function(ddl,record,index){{if(record.data.value!=Ext.get('{0}').dom.value){{{1}}}}}", LastSelectedValueHiddenID, GetPostBackEventReference());
            //    selectScript = String.Format("{0}.on('{1}',{2},X,{{delay:0}});", XID, "select", selectScript);
            //    //AddAbsoluteStartupScript( selectScript);
            //    autoPostBackScript += selectScript;

            //    //OB.Listeners.RemoveProperty(OptionName.Change);
            //    //OB.Listeners.AddProperty(OptionName.Change, String.Format("function(ddl,newValue,oldValue){{box_pageStateChange();alert(newValue+':'+oldValue);}}"), true);
            //}
            #endregion

            #endregion

            #region Listeners - render

            //string renderScript = "cmp.f_loadData();cmp.f_setValue();";

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

            #endregion

            #region AddStartupScript

            string contentScript = String.Format("var {0}=Ext.create('Ext.form.field.ComboBox',{1});", XID, OB.ToString());

            AddStartupScript(contentScript);

            #region old code
            //List<string> totalModifiedProperties = FState.GetTotalModifiedProperties();
            //StringBuilder loadDataSB = new StringBuilder();
            //if (totalModifiedProperties.Contains("F_Items"))
            //{
            //    loadDataSB.AppendFormat("{0}.f_loadData();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.store.loadData({1});", XID, F_Items.ToString());
            //}

            //if (totalModifiedProperties.Contains("SelectedValue"))
            //{
            //    loadDataSB.AppendFormat("{0}.f_setValue();", XID);
            //}
            //else
            //{
            //    loadDataSB.AppendFormat("{0}.f_setValue({1});", XID, JsHelper.Enquote(SelectedValue));
            //}
            #endregion

            #endregion
        }
Beispiel #32
0
        private string GetGridStore()
        {
            OptionBuilder storeBuilder = new OptionBuilder();

            // store - fields
            JsArrayBuilder fieldsBuidler = new JsArrayBuilder();
            foreach (GridColumn column in AllColumns)
            {
                JsObjectBuilder fieldBuilder = new JsObjectBuilder();
                fieldBuilder.AddProperty("name", column.ColumnID);

                if (AllowCellEditing)
                {
                    RenderBaseField field = column as RenderBaseField;
                    if (field != null)
                    {
                        if (field is RenderField)
                        {
                            RenderField renderFiled = field as RenderField;
                            if (renderFiled.FieldType != FieldType.Auto)
                            {
                                fieldBuilder.AddProperty("type", FieldTypeName.GetName(renderFiled.FieldType));
                                // 日期类型的,必须要设置这个 dateFormat 属性
                                if (renderFiled.FieldType == FieldType.Date)
                                {
                                    fieldBuilder.AddProperty("dateFormat", DateUtil.ConvertToClientDateFormat(renderFiled.RendererArgument));
                                }
                            }
                        }
                        else if (field is RenderCheckField)
                        {
                            fieldBuilder.AddProperty("type", "boolean");
                        }
                    }
                }
                fieldsBuidler.AddProperty(fieldBuilder);
            }

            // 增加 idProperty
            //JsObjectBuilder idFieldBuilder = new JsObjectBuilder();
            //idFieldBuilder.AddProperty("name", "__id");
            fieldsBuidler.AddProperty("__id");

            string fieldsScript = String.Format("var {0}={1};", Render_GridFieldsID, fieldsBuidler);


            // 自定义Model
            JsObjectBuilder modelOB = new JsObjectBuilder();
            modelOB.AddProperty("extend", "Ext.data.Model");
            modelOB.AddProperty("idProperty", "__id");
            modelOB.AddProperty("fields", Render_GridFieldsID, true);
            storeBuilder.AddProperty("model", String.Format("Ext.define(null,{0})", modelOB), true);

            //storeBuilder.AddProperty("fields", Render_GridFieldsID, true);

            storeBuilder.AddProperty("remoteSort", true);

            // add by wz
            if (EnableGroup)
                storeBuilder.AddProperty("groupField", GroupField);

            // 设置初始排序列
            if (AllowSorting)
            {
                string sortColumnID = GetSortColummID();
                if (!String.IsNullOrEmpty(sortColumnID))
                {
                    JsObjectBuilder sorterBuilder = new JsObjectBuilder();
                    sorterBuilder.AddProperty("property", GetSortColummID());
                    sorterBuilder.AddProperty("direction", SortDirection.ToString());
                    storeBuilder.AddProperty("sorters", sorterBuilder);
                }
            }


            string postbackScript = GetPostBackEventReference("#SORT#").Replace("'#SORT#'", "'Sort$'+sorter.property+'$'+sorter.direction");
            postbackScript = "var sorter=operation.sorters[0];if(sorter){" + postbackScript + "}return false;";

            storeBuilder.Listeners.AddProperty("beforeload", JsHelper.GetFunction(postbackScript, "store", "operation"), true);

            return fieldsScript + String.Format("var {0}=Ext.create('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);
            //// FineUIAjax回发并且Columns发生变化,需要重新
            //if (_FineUIAjaxColumnsChanged)
            //{
            //    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
        }
Beispiel #33
0
        protected override void OnFirstPreRender()
        {
            // 确保 X_Nodes 在页面第一次加载时都存在于 X_STATE 中,因为客户端需要这个数据来渲染树控件
            // 并且这个代码要放在 base.OnFirstPreRender(); 之前,因为在那里面会生成 X_STATE
            XState.AddModifiedProperty("X_Nodes");

            base.OnFirstPreRender();

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

            #region options

            OB.AddProperty("useArrows", EnableArrows);
            OB.AddProperty("animate", EnableAnimate);

            OB.AddProperty("singleExpand", EnableSingleExpand);
            OB.AddProperty("lines", EnableLines);

            if (!EnableIcons)
            {
                //bodyCssClass: 'x-tree-noicon'
                OB.AddProperty("bodyCls", "x-tree-noicon");
            }

            // 这个为了在客户端生成 PostBack 脚本,比如 __doPostBack('RegionPanel1$TreePanel1','')
            OB.AddProperty("name", UniqueID);

            #endregion

            #region oldcode

            //string hiddenFieldsScript = String.Empty;

            //// 选中的行
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(SelectedNodeHiddenFieldID, SelectedNode == null ? "" : SelectedNode.NodeID);

            //// 展开的行
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(ExpandedNodesHiddenFieldID, StringUtil.GetStringFromStringArray(GetExpandedNodeIDs()));

            //// 选中的行
            //hiddenFieldsScript += GetSetHiddenFieldValueScript(CheckedNodesHiddenFieldID, StringUtil.GetStringFromStringArray(GetCheckedNodeIDs()));

            #endregion

            #region Loader

            string loaderScript = String.Empty;

            JsObjectBuilder loaderBuilder = new JsObjectBuilder();
            //if (!String.IsNullOrEmpty(DataCallbackUrl))
            //{
            //    loaderBuilder.AddProperty("baseParams",String.Format("{{treeClientId:'{0}'}}", ClientID), true);
            //    loaderBuilder.AddProperty("dataUrl", DataCallbackUrl);

            //    JsObjectBuilder listenersBuilder = new JsObjectBuilder();
            //    listenersBuilder.AddProperty("load", String.Format("function(loader,node,response){{\r\nvar i =0;\r\n}}"), true);

            //    listenersBuilder.AddProperty(OptionName.Scope, "box", true);
            //    loaderBuilder.AddProperty("listeners", listenersBuilder);
            //}

            JsObjectBuilder listenersBuilder = new JsObjectBuilder();

            string paramStr = String.Format("Expand${0}", "#ID#");
            string postBackScript = GetPostBackEventReference(paramStr);
            postBackScript = postBackScript.Replace("#ID#'", "'+node.id");
            listenersBuilder.AddProperty("beforeload", String.Format("function(loader,node,callback){{{0}return false;}}", postBackScript), true);

            //listenersBuilder.AddProperty(OptionName.Scope, "box", true);
            loaderBuilder.AddProperty("listeners", listenersBuilder);
            // 必须添加dataUrl,才会引发beforeload事件
            loaderBuilder.AddProperty("dataUrl", "about:blank");
            loaderBuilder.AddProperty("preloadChildren", true);
            //loaderBuilder.AddProperty("clearOnLoad", false);

            loaderScript = String.Format("var {0}=new Ext.tree.TreeLoader({1});", Render_LoaderID, loaderBuilder);

            OB.AddProperty("loader", Render_LoaderID, true);

            #endregion

            #region selectModel

            string selectModelScript = String.Empty;
            if (EnableMultiSelect)
            {
                selectModelScript = "new Ext.tree.MultiSelectionModel()";
            }
            else
            {
                selectModelScript = "new Ext.tree.DefaultSelectionModel()";
            }
            OB.AddProperty("selModel", selectModelScript, true);

            #endregion

            #region old code

            // nodes
            //string nodesScript = Render_NodesId + "=[{'text':'Audi','id':100,'leaf':false,'cls':'folder','children':[{'text':'A3','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]},{'text':'TT','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]}]},{'text':'Cadillac','id':300,'leaf':false,'cls':'folder','children':[{'text':'CTS','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]},{'text':'CTS-V','id':1000,'leaf':false,'cls':'folder','children':[{'text':'FuelEconomy','id':'100000','leaf':true,'cls':'file'},{'text':'Invoice','id':'100001','leaf':true,'cls':'file'},{'text':'MSRP','id':'100002','leaf':true,'cls':'file'},{'text':'Options','id':'100003','leaf':true,'cls':'file'},{'text':'Specifications','id':'100004','leaf':true,'cls':'file'}]}]}];";
            //string nodesJsArray = GetNodesJsArray2(Nodes).ToString();
            //string nodesScript = String.Format("{0}={1};", Render_NodesID, nodesJsArray);

            #endregion

            #region Root

            //JsObjectBuilder rootBuilder = new JsObjectBuilder();
            ////rootBuilder.AddProperty(OptionName.Id, "root");
            ////rootBuilder.AddProperty(OptionName.Text, "root");
            ////rootBuilder.AddProperty("loaded", false);
            //rootBuilder.AddProperty(OptionName.Children, Render_NodesId, true);

            //string rootNodeScript = String.Format("var {0}=new Ext.tree.AsyncTreeNode({1});", Render_RootId, rootBuilder.ToString());
            //rootNodeScript += "\r\n";

            //OB.AddProperty("root", "new Ext.tree.AsyncTreeNode()", true);
            OB.AddProperty("rootVisible", false);

            #endregion

            #region renderScript

            //string renderScript = String.Empty;
            ////renderScript += "cmp.x_loadData();";
            //if (SelectedNodeIDArray.Length > 0)
            //{
            //    renderScript += "var model=cmp.getSelectionModel();";
            //    foreach (string nodeId in SelectedNodeIDArray)
            //    {
            //        renderScript += String.Format("model.select(cmp.getNodeById('{0}'),null,true);", nodeId);
            //    }
            //}

            ////renderScript = "function(cmp){window.setTimeout(function(){ cmp.x_loadData(); },1000);}";

            OB.Listeners.AddProperty("beforerender", JsHelper.GetFunction("cmp.x_loadData();", "cmp"), true);

            OB.Listeners.AddProperty("afterrender", JsHelper.GetFunction("cmp.x_selectNodes();", "cmp"), true);

            #endregion

            #region AddStartupScript
            //// 展开,折叠,点击,选中CheckBox事件处理函数,
            //// 因为这些函数会被几乎每个节点使用,所以提取出公共的方法来
            //scripts.AppendFormat("{0}=function(node){{X.util.addValueToHiddenField('{1}',node.id);}};", Render_NodeExpandScriptID, ExpandedNodesHiddenFieldID);
            //scripts.AppendFormat("{0}=function(node){{X.util.removeValueFromHiddenField('{1}',node.id);}};", Render_NodeCollapseScriptID, ExpandedNodesHiddenFieldID);
            //scripts.AppendFormat("{0}=function(node,checked){{if(checked){{X.util.addValueToHiddenField('{1}',node.id);}}else{{X.util.removeValueFromHiddenField('{1}',node.id);}}}};", Render_NodeCheckChangeScriptID, CheckedNodesHiddenFieldID);
            //scripts.AppendFormat("{0}=function(node){{Ext.get('{1}').dom.value=node.id;}};", Render_NodeClickScriptID, SelectedNodeHiddenFieldID);

            //scripts.AppendLine(hiddenFieldsScript);

            StringBuilder scripts = new StringBuilder();

            scripts.AppendLine(loaderScript);
            scripts.AppendFormat("{0}=new Ext.tree.TreePanel({1});", XID, OB);

            AddStartupScript(scripts.ToString());

            #endregion
        }
Beispiel #34
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            // 确保 F_Rows 在页面第一次加载时都存在于f_state中
            FState.AddModifiedProperty("F_Rows");
            if (EnableSummary)
            {
                FState.AddModifiedProperty("SummaryData");
            }
            if (SelectedRowIDArray.Length > 0)
            {
                FState.AddModifiedProperty("SelectedRowIDArray");
            }

            // 不需要手工添加 SelectedRowIndexArray 属性,是因为只能通过代码设置此属性
            // 只要通过代码设置了 SelectedRowIndexArray 属性,则一定会存在于 F_States


            base.OnFirstPreRender();


            //ResourceManager.Instance.AddJavaScriptComponent("grid");
            JsArrayBuilder pluginBuilder = new JsArrayBuilder();

            #region selectModel/gridStore/gridColumn

            #region old code
            //string dataScript = "var grid_data=[['My_Item1The id of a column in this grid that should expand to fill unused space. This id can not be 0.','1','2008'],['My_Item2','2','2007']];";
            //string storeScript = "var grid_store = new Ext.data.SimpleStore({fields:[{name:'name1'},{name:'value'},{name:'year'}]});\r\ngrid_store.loadData(grid_data);";
            //string storeScript = "var grid_store = new Ext.data.SimpleStore({fields:['name1','value1','year1'],data:[['My_Item1The id of a column in this grid that should expand to fill unused space. This id can not be 0.','1','2008'],['My_Item2','2','2007']]});";
            //OB.AddProperty(OptionName.Columns, "[{id:'name2', header: 'Price', sortable: true},{header: 'Price2', sortable: true},{header: 'Price3', sortable: true}]", true);

            #endregion

            string gridSelectModelScript = GetGridSelectModel();
            OB.AddProperty("selModel", Render_SelectModelID, true);


            string gridColumnsScript = GetGridColumnScript(pluginBuilder);
            OB.AddProperty("columns", Render_GridColumnsID, true);

            string gridStoreScript = GetGridStore();
            OB.AddProperty("store", Render_GridStoreID, true);

            OB.AddProperty("f_fields", Render_GridFieldsID, true);
            //Console.WriteLine(RowExpander.DataFields);

            #endregion

            #region Width

            //if (MinColumnWidth != Unit.Empty)
            //{
            //    OB.AddProperty("minColumnWidth", MinColumnWidth.Value);
            //}

            //string autoExpandColumnID = AutoExpandColumn; // GetAutoExpandColumnID();
            //if (String.IsNullOrEmpty(autoExpandColumnID))
            //{
            //    autoExpandColumnID = GetAutoExpandColumnID();
            //}

            //if (!String.IsNullOrEmpty(autoExpandColumnID))
            //{
            //    OB.AddProperty("autoExpandColumn", autoExpandColumnID);

            //    if (AutoExpandColumnMax != Unit.Empty)
            //    {
            //        OB.AddProperty("autoExpandMax", AutoExpandColumnMax.Value);
            //    }

            //    if (AutoExpandColumnMin != Unit.Empty)
            //    {
            //        OB.AddProperty("autoExpandMin", AutoExpandColumnMin.Value);
            //    }
            //}



            #endregion

            #region viewConfig

            JsObjectBuilder viewBuilder = new JsObjectBuilder();
            if (!String.IsNullOrEmpty(EmptyText))
            {
                viewBuilder.AddProperty("deferEmptyText", false);
                viewBuilder.AddProperty("emptyText", EmptyText);
            }

            if (!EnableAlternateRowColor)
            {
                viewBuilder.AddProperty("stripeRows", false);
            }

            if (EnableTextSelection)
            {
                viewBuilder.AddProperty("enableTextSelection", true);
            }

            viewBuilder.AddProperty("getRowClass", JsHelper.GetFunction("return 'f-grid-row';"), true);
            //viewBuilder.AddProperty("selectedItemCls", "x-grid-row-selected f-grid-row-selected");

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


            #endregion

            #region Properties

            if (!String.IsNullOrEmpty(DataIDField))
            {
                OB.AddProperty("f_idField", DataIDField);
            }



            if (EnableColumnLines)
            {
                OB.AddProperty("columnLines", true);
            }

            if (!EnableRowLines)
            {
                OB.AddProperty("rowLines", false);
            }



            if (ForceFit)
            {
                OB.AddProperty("forceFit", true);
            }

            //OB.AddProperty("enableHdMenu", EnableHeaderMenu);

            //if (EnableHeaderMenu)
            //{
            //    // 启用标题栏菜单,但是不启用标题栏菜单中的隐藏列功能
            //    if (!EnableColumnHide)
            //    {
            //        OB.AddProperty("enableColumnHide", false);
            //    }
            //}



            if (!ShowGridHeader)
            {
                OB.AddProperty("hideHeaders", true);
            }

            if (!EnableMouseOverColor)
            {
                OB.AddProperty("trackMouseOver", false);
            }

            // 延迟渲染
            if (!EnableDelayRender)
            {
                OB.AddProperty("deferRowRender", false);
            }



            #endregion

            #region EnableRowClickEvent

            if (EnableRowClickEvent)
            {
                string validateScript = "var args='RowClick$'+record.getId();";
                validateScript += GetPostBackEventReference("#RowClick#").Replace("'#RowClick#'", "args");

                //string rowClickScript = JsHelper.GetFunction(validateScript, "grid", "record", "item", "index"); // String.Format("function(grid,rowIndex,e){{{0}}}", validateScript);

                //OB.Listeners.AddProperty("itemclick", rowClickScript, true);
                AddListener("itemclick", validateScript, "grid", "record", "item", "index");
            }

            if (EnableRowDoubleClickEvent)
            {
                string validateScript = "var args='RowDoubleClick$'+record.getId();";
                validateScript += GetPostBackEventReference("#RowDoubleClick#").Replace("'#RowDoubleClick#'", "args");

                //string rowClickScript = JsHelper.GetFunction(validateScript, "grid", "record", "item", "index"); //String.Format("function(grid,rowIndex,e){{{0}}}", validateScript);

                //OB.Listeners.AddProperty("itemdblclick", rowClickScript, true);
                AddListener("itemdblclick", validateScript, "grid", "record", "item", "index");
            }

            #endregion

            #region AllowPaging

            string pagingScript = String.Empty;

            if (AllowPaging)
            {
                OptionBuilder pagingBuilder = GetPagingBuilder();

                if (!ShowPagingMessage)
                {
                    pagingBuilder.AddProperty("displayInfo", false);
                }
                else
                {
                    pagingBuilder.AddProperty("displayInfo", true);
                }

                pagingBuilder.AddProperty("store", Render_GridStoreID, true);
                //// Hide refresh button, we don't implement this logic now.
                //pagingBuilder.Listeners.AddProperty("beforerender", JsHelper.GetFunction("this.f_hideRefresh();"), true);

                string postbackScript = String.Empty;
                postbackScript = GetPostBackEventReference("#PLACEHOLDER#");
                string loadPageScript = JsHelper.GetFunction(postbackScript.Replace("'#PLACEHOLDER#'", "'Page$'+(pageNum-1)") + "return false;", "bar", "pageNum");

                pagingBuilder.Listeners.AddProperty("beforechange", loadPageScript, true);


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

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

                pagingBuilder.AddProperty("xtype", "simplepagingtoolbar");
                pagingBuilder.AddProperty("dock", "bottom");

                pagingScript = String.Format("var {0}={1};", Render_PagingID, pagingBuilder);

                //OB.AddProperty("bbar", Render_PagingID, true);
            }

            #endregion

            #region remove fx

            OB.AddProperty("draggable", false);
            //OB.AddProperty("enableColumnMove", false);
            OB.AddProperty("enableDragDrop", false);

            if (!EnableColumnResize)
            {
                OB.AddProperty("enableColumnResize", false);
            }

            #endregion

            #region AllowSorting


            //// 如果启用服务器端排序,则需要注册headerclick事件处理
            //if (AllowSorting)
            //{
            //    string headerClickScript = "if(!cmp.getColumnModel().config[columnIndex].sortable){return false;}";
            //    headerClickScript += "var args='Sort$'+columnIndex;";
            //    headerClickScript += GetPostBackEventReference("#SORT#").Replace("'#SORT#'", "args");

            //    // 告诉 store 本次排序已经处理了,不要重复处理了
            //    headerClickScript += "cmp.getStore().headerclickprocessed=true;";

            //    //string headerClickScript = String.Format("function(grid,columnIndex){{{0}}}", validateScript);
            //    OB.Listeners.AddProperty("headerclick", JsHelper.GetFunction(headerClickScript, "cmp", "columnIndex"), true);
            //}

            // add by wz
            if (!AllowSorting)
            {
                OB.AddProperty("sortableColumns", false);
            }

            #endregion

            // add by wz
            #region enableColumnHide

            if (!EnableColumnHide)
                OB.AddProperty("enableColumnHide", false);

            #endregion

            // mod by wz
            #region EnableSummary

            //JsArrayBuilder features = new JsArrayBuilder();

            //if (EnableSummary)
            //{
            //    JsObjectBuilder summaryFeature = new JsObjectBuilder();
            //    summaryFeature.AddProperty("ftype", "summary");
            //    summaryFeature.AddProperty("id", "summary");

            //    if (SummaryPosition != SummaryPosition.Flow)
            //    {
            //        summaryFeature.AddProperty("dock", SummaryPositionHelper.GetName(SummaryPosition));
            //    }

            //    //if (SummaryHidden)
            //    //{
            //    //    summaryFeature.AddProperty("showSummaryRow", false);
            //    //}

            //    features.AddProperty(summaryFeature);
            //}


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

            #endregion

            // add by wz
            #region Enable Group & Summary

            JsArrayBuilder features = new JsArrayBuilder();

            if (EnableGroup && EnableSummary)
            {
                JsObjectBuilder groupingSummaryFeature = new JsObjectBuilder();

                groupingSummaryFeature.AddProperty("ftype", "groupingsummary");
                groupingSummaryFeature.AddProperty("id", "groupingsummary");

                //if (SummaryPosition != SummaryPosition.Flow)
                //{
                //    groupingSummaryFeature.AddProperty("dock", SummaryPositionHelper.GetName(SummaryPosition));
                //}

                if (!string.IsNullOrEmpty(GroupHeader))
                    groupingSummaryFeature.AddProperty("groupHeaderTpl", GroupHeader, true);
                if (!EnableGroupCollapse)
                    groupingSummaryFeature.AddProperty("collapsible", EnableGroupCollapse);
                if (!EnableGroupMenu)
                    groupingSummaryFeature.AddProperty("enableGroupingMenu", EnableGroupMenu);
                if (GroupStartCollapsed)
                    groupingSummaryFeature.AddProperty("startCollapsed", GroupStartCollapsed);

                features.AddProperty(groupingSummaryFeature);
            }
            else if (EnableSummary)
            {
                JsObjectBuilder summaryFeature = new JsObjectBuilder();
                summaryFeature.AddProperty("ftype", "summary");
                summaryFeature.AddProperty("id", "summary");

                if (SummaryPosition != SummaryPosition.Flow)
                {
                    summaryFeature.AddProperty("dock", SummaryPositionHelper.GetName(SummaryPosition));
                }

                //if (SummaryHidden)
                //{
                //    summaryFeature.AddProperty("showSummaryRow", false);
                //}

                features.AddProperty(summaryFeature);
            }
            else if (EnableGroup)
            {
                JsObjectBuilder groupFeature = new JsObjectBuilder();
                groupFeature.AddProperty("ftype", "grouping");
                groupFeature.AddProperty("id", "grouping");

                if (!string.IsNullOrEmpty(GroupHeader))
                    groupFeature.AddProperty("groupHeaderTpl", GroupHeader, true);
                if (!EnableGroupCollapse)
                    groupFeature.AddProperty("collapsible", EnableGroupCollapse);
                if (!EnableGroupMenu)
                    groupFeature.AddProperty("enableGroupingMenu", EnableGroupMenu);
                if (GroupStartCollapsed)
                    groupFeature.AddProperty("startCollapsed", GroupStartCollapsed);

                features.AddProperty(groupFeature);
            }

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

            #endregion

            #region Listeners - afterrender

            StringBuilder viewreadySB = new StringBuilder();

            // Note: this.f_state['F_Rows']['Values'] will always rendered to the client side.
            //viewreadySB.Append("cmp.f_updateTpls();");

            if (AllowSorting)
            {
                viewreadySB.AppendFormat("cmp.f_initSortHeaders();");
            }

            if (!AllowCellEditing)
            {
                viewreadySB.Append("cmp.f_selectRows();");
            }


            //if (EnableTextSelection)
            //{
            //    cls += " x-grid-selectable";

            //    viewreadySB.Append("cmp.f_enableTextSelection();");
            //}

            // 展开所有的行扩展列
            if (ExpandAllRowExpanders)
            {
                viewreadySB.Append("cmp.f_expandAllRows();");
            }

            if (AllowColumnLocking)
            {
                // 必须延时调用 doLayout,否则显示不正常
                viewreadySB.Append("cmp.doLayout();");
            }

            string viewreadyScript = viewreadySB.ToString();

            if (!String.IsNullOrEmpty(viewreadyScript))
            {
                viewreadyScript = "window.setTimeout(function(){" + viewreadyScript + "},200);";

                // viewready在enableLocking时不会触发,只好改成afterrender
                //OB.Listeners.AddProperty("afterrender", JsHelper.GetFunction(viewreadyScript, "cmp"), true);
                AddListener("afterrender", viewreadyScript, "cmp");
            }

            #endregion

            #region cls

            string cls = CssClass;

            if (RowVerticalAlign != VerticalAlign.Middle)
            {
                cls += String.Format("row-align-{0}", VerticalAlignName.GetName(RowVerticalAlign));
            }

            cls = cls.Trim();
            if (!String.IsNullOrEmpty(cls))
            {
                OB.AddProperty("cls", cls);
            }

            #endregion

            #region Listeners - render

            StringBuilder renderSB = new StringBuilder();

            // 加载表格数据
            renderSB.Append("cmp.f_loadData();");

            //// 隐藏列
            //if (HiddenColumnIndexArray != null && HiddenColumnIndexArray.Length > 0)
            //{
            //    renderSB.Append("cmp.f_updateColumnsHiddenStatus();");
            //}

            //OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderSB.ToString(), "cmp"), true);
            AddListener("render", renderSB.ToString(), "cmp");

            #endregion

            #region AllowCellEditing

            string cellEditScript = String.Empty;

            if (AllowCellEditing)
            {
                string pluginId = String.Format("{0}_cellEditing", XID);

                JsObjectBuilder cellEditBuilder = new JsObjectBuilder();
                cellEditBuilder.AddProperty("pluginId", pluginId);
                cellEditBuilder.AddProperty("clicksToEdit", ClicksToEdit);

                cellEditScript = String.Format("var {0}=Ext.create('Ext.grid.plugin.CellEditing',{1});", pluginId, cellEditBuilder);

                pluginBuilder.AddProperty(pluginId, true);

                if (EnableAfterEditEvent)
                {
                    string validateScript = "var args='AfterEdit$'+e.record.getId()+'$'+e.column.id;";
                    validateScript += GetPostBackEventReference("#AfterEdit#").Replace("'#AfterEdit#'", "args");

                    //string rowClickScript = String.Format("function(editor,e){{{0}}}", validateScript);
                    //OB.Listeners.AddProperty("edit", rowClickScript, true);
                    AddListener("edit", validateScript, "editor", "e");
                }

                OB.AddProperty("f_cellEditing", pluginId, true);
            }


            if (AllowColumnLocking)
            {
                OB.AddProperty("enableLocking", true);
            }
            else
            {
                OB.AddProperty("enableLocking", false);
            }

            #endregion

            #region pluginBuilder

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

            #endregion

            StringBuilder sb = new StringBuilder();
            sb.Append(gridSelectModelScript + gridStoreScript + pagingScript + gridColumnsScript + cellEditScript);
            sb.AppendFormat("var {0}=Ext.create('Ext.grid.Panel',{1});", XID, OB);

            AddStartupScript(sb.ToString());

            #region old code

            ////List<string> totalModifiedProperties = FState.GetTotalModifiedProperties();
            ////if (SelectedRowIndexArray.Length > 0)
            ////{
            ////    string selectScript = String.Empty;
            ////    if (totalModifiedProperties.Contains("SelectedRowIndexArray"))
            ////    {
            ////        selectScript = String.Format("{0}.f_selectRows();", XID);
            ////    }
            ////    else
            ////    {
            ////        selectScript = String.Format("{0}.selectRows({1});", Render_SelectModelID, new JArray(SelectedRowIndexArray));
            ////    }
            ////    sb.Append(JsHelper.GetDeferScript(selectScript, 200));
            ////}

            //// Make sure SelectedRowIndexArray property exist in F_STATE during page's first load.
            //sb.Append(JsHelper.GetDeferScript(String.Format("{0}.f_selectRows();", XID), 200));

            #endregion

            // add by wz
            #region GroupEvent

            if (EnableGroupCollapseEvent)
            {
                string function = "var args='GroupCollapse$'+group;";
                function += GetPostBackEventReference("#GroupCollapse#").Replace("'#GroupCollapse#'", "args");
                string script = string.Format("{0}.getView().on('groupcollapse', function(view, node, group){{ {1} }});", XID, function);

                PageContext.RegisterStartupScript(script);
            }
            if (EnableGroupExpandEvent)
            {
                string function = "var args='GroupExpand$'+group;";
                function += GetPostBackEventReference("#GroupExpand$#").Replace("'#GroupExpand$#'", "args");
                string script = string.Format("{0}.getView().on('groupexpand', function(view, node, group){{ {1} }});", XID, function);

                PageContext.RegisterStartupScript(script);
            }
            if (EnableGroupClickEvent)
            {
                string function = "var args='GroupClick$'+group;";
                function += GetPostBackEventReference("#GroupClick#").Replace("'#GroupClick#'", "args");
                string script = string.Format("{0}.getView().on('groupclick', function(view, node, group){{ {1} }});", XID, function);

                PageContext.RegisterStartupScript(script);
            }
            if (EnableGroupDoubleClickEvent)
            {
                string function = "var args='GroupDoubleClick$'+group;";
                function += GetPostBackEventReference("#GroupDoubleClick#").Replace("'#GroupDoubleClick#'", "args");
                string script = string.Format("{0}.getView().on('groupdblclick', function(view, node, group){{ {1} }});", XID, function);

                PageContext.RegisterStartupScript(script);
            }

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


            OB.AddProperty("border", false);
            OB.AddProperty("header", false);

            Form parentForm = Parent as Form;
            if (parentForm == null)
            {
                return;
            }

            int formrowItemsSpace = Convert.ToInt32(parentForm.FormRowItemsSpace.Value);


            if (Items.Count > 0)
            {
                #region oldcode
                /*
                 * 增加中间的分割面板,会对显示隐藏表单字段造成影响
                int currentItemCount = 0;
                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (ControlBase item in Items)
                {
                    if (item.Visible)
                    {
                        if (currentItemCount > 0)
                        {
                            OptionBuilder separatorOB = new OptionBuilder();
                            separatorOB.AddProperty("type", "panelbase");
                            separatorOB.AddProperty("width", 8);
                            ab.AddProperty(String.Format("{0}", separatorOB), true);
                        }
                        ab.AddProperty(String.Format("{0}", item.XID), true);
                        currentItemCount++;
                    }
                }
                OB.AddProperty("items", ab.ToString(), true);
                */

                #endregion

                // 为子项添加布局属性
                int columnCount = Items.Count;
                string defaultColumnWidthStr = (1.0 / columnCount).ToString("F2", System.Globalization.CultureInfo.InvariantCulture);
                List<string> columnWidths = GetTrimedColumnWidths();

                // 用户自定义ColumnWidths是否和Items的个数匹配
                bool isColumnWidthsMatch = false;
                if (columnWidths.Count == columnCount)
                {
                    isColumnWidthsMatch = true;
                }

                Dictionary<string, JsObjectBuilder> buttonOptions = new Dictionary<string, JsObjectBuilder>();
                for (int i = 0; i < columnCount; i++)
                {
                    var comp = Items[i] as Component;

                    // 如果FormRow的子项是 Button,则用一个面板将其包裹起来,否则按钮的宽度会很长
                    bool isbutton = false;
                    JsObjectBuilder buttonPanelOB = new JsObjectBuilder();
                    if (comp is Button)
                    {
                        isbutton = true;

                        buttonPanelOB.AddProperty("xtype", "panel");
                        buttonPanelOB.AddProperty("header", false);
                        buttonPanelOB.AddProperty("border", false);

                        buttonPanelOB.AddProperty("items", String.Format("[{0}]", comp.XID), true);
                    }

                    #region Component
                    if (comp != null)
                    {
                        // 不是最后一列的话,加上空白间隔
                        if (columnCount > 1 && i != columnCount - 1)
                        {
                            if (isbutton)
                            {
                                //buttonOB.AddProperty("marginRight", formrowItemsSpace);
                                buttonPanelOB.AddProperty("style", String.Format("margin-right:{0}px;", formrowItemsSpace));
                            }
                            else
                            {
                                //// 如果尚未设置 MarginRight
                                //if (comp.MarginRight == Unit.Empty)
                                //{
                                //    comp.MarginRight = Unit.Pixel(formrowItemsSpace);
                                //}
                                //if (String.IsNullOrEmpty(comp.Margin))
                                //{
                                //    comp.Margin = String.Format("0 {0} 0 0", formrowItemsSpace);
                                //}
                                comp.CssStyle += String.Format("margin-right:{0}px;", formrowItemsSpace);
                            }
                        }
                    }
                    #endregion

                    #region BoxComponent
                    var boxcomp = comp as BoxComponent;
                    if (boxcomp != null)
                    {
                        if (isColumnWidthsMatch)
                        {
                            string columnWidth = StringUtil.ConvertPercentageToDecimalString(columnWidths[i]);
                            if (Convert.ToDouble(columnWidth) <= 1.0)
                            {
                                if (isbutton)
                                {
                                    buttonPanelOB.AddProperty("columnWidth", columnWidth, true);
                                }
                                else
                                {
                                    boxcomp.ColumnWidth = columnWidth;
                                }
                            }
                            else
                            {
                                Unit unitColumnWidth = Unit.Parse(columnWidth);

                                if (isbutton)
                                {
                                    buttonPanelOB.AddProperty("width", unitColumnWidth.Value);
                                }
                                else
                                {
                                    boxcomp.Width = unitColumnWidth;
                                }
                            }
                        }
                        else
                        {
                            if (isbutton)
                            {
                                buttonPanelOB.AddProperty("columnWidth", defaultColumnWidthStr, true);
                            }
                            else
                            {
                                boxcomp.ColumnWidth = defaultColumnWidthStr;
                            }
                        }
                    }
                    #endregion

                    if (isbutton)
                    {
                        buttonOptions.Add(comp.XID, buttonPanelOB);
                    }
                }


                JsArrayBuilder ab = new JsArrayBuilder();
                foreach (ControlBase item in Items)
                {
                    if (item.Visible)
                    {
                        string itemXID = item.XID;
                        if (buttonOptions.ContainsKey(itemXID))
                        {
                            itemXID = buttonOptions[itemXID].ToString();
                        }

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

            // 自定义样式
            OB.AddProperty("cls", "f-formrow");

            string jsContent = String.Format("var {0}=Ext.create('Ext.panel.Panel',{1});", XID, OB.ToString());
            AddStartupScript(jsContent);
            
            ////// 目的:子控件的JS代码在父控件的前面
            ////AddStartupScript(this, String.Empty);
            //AddStartupScript(String.Empty);
        }
Beispiel #36
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            // 不渲染
            RenderWrapperNode = false;

            // 这个是必须的,2009-08-04
            // 因为每个页面都会有 PageManager 控件,每个页面要至少调用 GetPostBackEventReference 一次,以在页面产生 __doPostBack 函数。
            Page.ClientScript.GetPostBackEventReference(this, "");

            // Move it to ResourceManager.cs
            // 为页面的 Form 添加 autocomplete="off" 属性
            // 参考http://www.cnblogs.com/sanshi/archive/2009/09/04/1560146.html#1635830
            // Page.Form.Attributes["autocomplete"] = "off";

            #region HideScrollbars

            if (HideScrollbars)
            {
                //if (Page.Request.UserAgent.ToLower().Contains("msie"))
                //{
                //    //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "noscroll", String.Format("window.document.body.scroll='no';"), true);
                //    AddStartupAbsoluteScript("window.document.body.scroll='no';");
                //}
                //else
                //{
                //    //Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "noscroll",  String.Format("window.document.body.style.overflow='hidden';"), true);
                //    AddStartupAbsoluteScript("window.document.body.style.overflow='hidden';");
                //}
                AddStartupAbsoluteScript("F.util.hideScrollbar();");
            }

            #endregion

            #region oldcode

            //if (!PageLoadingControlExist)
            //{
            //    string jsContent = String.Empty;

            //    if (EnablePageLoading)
            //    {
            //        jsContent += "F.util.removePageLoading(false);";
            //    }

            //    AddStartupAbsoluteScript(jsContent);
            //}


            #endregion

            //#region EnableAjax

            //if (!EnableAjax)
            //{
            //    AddStartupAbsoluteScript("F.global_disable_ajax=true;");
            //}

            //#endregion

            #region AutoSizePanelID

            if (!String.IsNullOrEmpty(AutoSizePanelID))
            {
                PanelBase autosizePanel = ControlUtil.FindControl(Page.Form, AutoSizePanelID) as PanelBase;

                if (autosizePanel != null)
                {
                    #region oldcode
                    //string resizePanelScript = String.Empty;

                    //resizePanelScript += String.Format("{0}_resize_outerpanel=function(){{var panel=Ext.getCmp('{1}');panel.setSize(Ext.getBody().getSize());panel.doLayout();}};", ClientJavascriptID, panel.ClientID);
                    //resizePanelScript += String.Format("{0}_resize_outerpanel();", ClientJavascriptID);
                    //resizePanelScript += String.Format("if(Ext.isIE){{X.{0}_resize_outerpanel.defer(60);}}", ClientJavascriptID);
                    //resizePanelScript += String.Format("Ext.EventManager.onWindowResize(function(){{X.{0}_resize_outerpanel();}},box);", ClientJavascriptID);

                    //AddAbsoluteStartupScript(resizePanelScript);

                    // X._3=new Ext.FormViewport({renderTo:"RegionPanel1_wrapper",id:"RegionPanel1",layout:"border",items:[X._1,X._2],bodyStyle:"",border:false,animCollapse:false});

                    #endregion

                    // 子节点不向页面输出HTML,此PageManager向页面输出HTML
                    autosizePanel.RenderWrapperNode = false;
                    RenderWrapperNode = true;

                    OB.AddProperty("layout", "fit");
                    OB.AddProperty("border", false);
                    OB.AddProperty("items", String.Format("{0}", autosizePanel.XID), true);

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

                    // 确保FormViewport脚本在所以用户自定义脚本(PageContext.RegisterStartupScript)之前执行
                    AddStartupAbsoluteScript(jsContent, Constants.ABSOLUTE_STARTUP_SCRIPT_DEFAULT_LEVEL - 20);
                }
            }

            #endregion

            //if (EnableBigFont)
            //{
            //    AddStartupAbsoluteScript("Ext.getBody().addClass('bigfont');");
            //}

            #region oldcode

            // Move to F.util.init
            // Asp.Net Buttons(type="submit")
            // AddStartupAbsoluteScript("F.util.makeAspnetSubmitButtonAjax();");

            #endregion

            JsObjectBuilder job = new JsObjectBuilder();

            job.AddProperty("name", UniqueID);

            if (ValidateForms != null && ValidateForms.Length > 0)
            {
                JsObjectBuilder validate = new JsObjectBuilder();
                validate.AddProperty("forms", ControlUtil.GetControlClientIDs(ValidateForms));
                validate.AddProperty("target", TargetHelper.GetName(ValidateTarget));
                validate.AddProperty("messagebox", ValidateMessageBox.ToString().ToLower());
                job.AddProperty("validate", validate);

            }

            string createScript = String.Format("F.f_pagemanager={1};", XID, job);
            AddStartupScript(createScript);
        }
Beispiel #37
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region Options

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

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


            #endregion

            
        }
Beispiel #38
0
        /// <summary>
        /// 获取显示确认对话框的客户端脚本
        /// </summary>
        /// <param name="message">对话框消息</param>
        /// <param name="title">对话框标题</param>
        /// <param name="icon">对话框图标</param>
        /// <param name="okScriptstring">点击确定按钮执行的客户端脚本</param>
        /// <param name="cancelScript">点击取消按钮执行的客户端脚本</param>
        /// <param name="target">弹出对话框的目标页面</param>
        /// <returns>客户端脚本</returns>
        public static string GetShowReference(string message, string title, MessageBoxIcon icon, string okScriptstring, string cancelScript, Target target)
        {
            //string msgBoxScript = "var msgBox=Ext.MessageBox;";
            //msgBoxScript += "if(parent!=window){msgBox=parent.window.Ext.MessageBox;}";
            if (String.IsNullOrEmpty(title))
            {
                title = "X.util.confirmTitle";
            }
            else
            {
                title = JsHelper.GetJsString(title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }
            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");

            JsObjectBuilder ob = new JsObjectBuilder();
            ob.AddProperty("title", title, true);
            ob.AddProperty("msg", JsHelper.GetJsStringWithScriptTag(message), true);
            ob.AddProperty("buttons", "Ext.MessageBox.OKCANCEL", true);
            ob.AddProperty("icon", String.Format("{0}", MessageBoxIconHelper.GetName(icon)), true);
            ob.AddProperty("fn", String.Format("function(btn){{if(btn=='cancel'){{{0}}}else{{{1}}}}}", cancelScript, okScriptstring), true);

            string targetName = "window";
            if (target != Target.Self)
            {
                targetName = TargetHelper.GetScriptName(target);
            }
            return String.Format("{0}.Ext.MessageBox.show({1});", targetName, ob.ToString());
        }
Beispiel #39
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            if (Layout != Layout.Container)
            {
                //OB.AddProperty("layout", LayoutHelper.GetName(Layout));
                string layoutName = LayoutHelper.GetName(Layout);

                JsObjectBuilder layoutConfigOB = new JsObjectBuilder();
                if (Layout == Layout.Table)
                {
                    layoutConfigOB.AddProperty("columns", TableConfigColumns);

                }
                else if (Layout == Layout.HBox || Layout == Layout.VBox)
                {
                    if (BoxConfigAlign != BoxLayoutAlign.Top)
                    {
                        layoutConfigOB.AddProperty("align", BoxLayoutAlignHelper.GetName(BoxConfigAlign, Layout));
                    }

                    if (BoxConfigPosition != BoxLayoutPosition.Left)
                    {
                        layoutConfigOB.AddProperty("pack", BoxLayoutPositionHelper.GetName(BoxConfigPosition));
                    }

                    if (BoxConfigPadding != "0")
                    {
                        layoutConfigOB.AddProperty("padding", BoxConfigPadding);
                    }

                    if (BoxConfigChildMargin != "0")
                    {
                        layoutConfigOB.AddProperty("defaultMargins", BoxConfigChildMargin);
                    }
                }

                if (layoutConfigOB.Count > 0)
                {
                    layoutConfigOB.AddProperty("type", layoutName);

                    OB.AddProperty("layout", layoutConfigOB);
                }
                else
                {
                    OB.AddProperty("layout", layoutName);
                }

            }
        }
Beispiel #40
0
        /// <summary>
        /// 获取添加选项卡的脚本
        /// </summary>
        /// <param name="tabID">选项卡ID</param>
        /// <param name="iframeUrl">IFrame地址</param>
        /// <param name="tabTitle">选项卡标题</param>
        /// <param name="iconUrl">选项卡图标</param>
        /// <param name="enableClose">是否可以关闭</param>
        /// <returns>客户端脚本</returns>
        public string GetAddTabReference(string tabID, string iframeUrl, string tabTitle, string iconUrl, bool enableClose)
        {
            if (!String.IsNullOrEmpty(iframeUrl))
            {
                iframeUrl = ResolveIFrameUrl(iframeUrl);
            }

            JsObjectBuilder options = new JsObjectBuilder();
            options.AddProperty("id", tabID);
            options.AddProperty("url", iframeUrl);
            options.AddProperty("title", tabTitle);
            options.AddProperty("closable", enableClose);

            string iconScript = String.Empty;
            if (!String.IsNullOrEmpty(iconUrl))
            {
                string className = String.Format("icon_{0}", System.Guid.NewGuid().ToString("N"));
                iconScript = String.Format("F.addCSS('{0}','{1}');", className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(iconUrl)));

                options.AddProperty("iconCls", className);
            }

            return iconScript + String.Format("{0}.addTab({1});", ScriptID, options);
        }
Beispiel #41
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        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

            JsObjectBuilder layoutOB = new JsObjectBuilder();
            layoutOB.AddProperty("pack", ToolbarAlignHelper.GetName(ToolbarAlign));

            OB.AddProperty("layout", layoutOB, true);

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

            //string jsContent = String.Format("var {0}={1};", XID, OB.GetProperty("items"));
            string jsContent = String.Format("var {0}={1};", XID, OB.ToString());

            AddStartupScript(jsContent);
        }
Beispiel #42
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            string message = "";
            string title = "";
            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }


            JsObjectBuilder jsOB = new JsObjectBuilder();

            if (!String.IsNullOrEmpty(CancelScript))
            {
                jsOB.AddProperty("cancel", CancelScript);
            }

            if (!String.IsNullOrEmpty(OkScript))
            {
                jsOB.AddProperty("ok", OkScript);
            }

            if (Target != Target.Self)
            {
                jsOB.AddProperty("target", TargetHelper.GetName(Target));
            }

            if (MessageBoxIcon != MessageBoxIcon.Warning)
            {
                jsOB.AddProperty("messageIcon", MessageBoxIconHelper.GetShortName(MessageBoxIcon));
            }

            if (!String.IsNullOrEmpty(title))
            {
                jsOB.AddProperty("title", title.Replace("\r\n", "\n").Replace("\n", "<br/>"));
            }

            if (!String.IsNullOrEmpty(message))
            {
                jsOB.AddProperty("message", JsHelper.EnquoteWithScriptTag(message.Replace("\r\n", "\n").Replace("\n", "<br/>")), true);
            }

            return String.Format("F.confirm({0});", jsOB.ToString());
        }
Beispiel #43
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 jsContent = String.Format("var {0}=new Ext.Panel({1});", XID, OB.ToString());
            AddStartupScript(jsContent);
        }