/// <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); } } }
internal override string GetHeaderValue() { if (!RenderAsStaticField && ShowHeaderCheckBox) { string result = String.Empty; string textAlignClass = String.Empty; if (TextAlign != TextAlign.Left) { textAlignClass = "box-grid-checkbox-" + TextAlignName.GetName(TextAlign); } string onClickScript = "Ext.get(this).toggleClass('box-grid-checkbox-unchecked');"; onClickScript += "X.util.stopEventPropagation.apply(null, arguments);"; //string tooltip = String.Empty; //if (!String.IsNullOrEmpty(HeaderText)) //{ // tooltip = String.Format(" ext:qtip=\"{0}\" ", HeaderText); //} result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-unchecked {0}\" onclick=\"{1}\">{2}</div>", textAlignClass, onClickScript, HeaderText); return(result); } else { return(base.GetHeaderValue()); } }
internal override string GetHeaderValue() { if (!RenderAsStaticField && ShowHeaderCheckBox) { string result = String.Empty; string textAlignClass = String.Empty; if (TextAlign != TextAlign.Left) { textAlignClass = "align-" + TextAlignName.GetName(TextAlign); } string onClickScript = "X.toggle(this,'unchecked');"; //onClickScript += "X.stop();"; //string tooltip = String.Empty; //if (!String.IsNullOrEmpty(HeaderText)) //{ // tooltip = String.Format(" ext:qtip=\"{0}\" ", HeaderText); //} result = String.Format("<div class=\"box-grid-checkbox unchecked {0}\" onclick=\"{1}\">{2}</div>", textAlignClass, onClickScript, HeaderText); return(result); } else { return(base.GetHeaderValue()); } }
/// <summary> /// 渲染 HTML 之前调用(页面第一次加载或者普通回发) /// </summary> protected override void OnFirstPreRender() { base.OnFirstPreRender(); if (this is TemplateField && (this as TemplateField).RenderAsRowExpander) { // 行扩展列需要特殊处理 } else { //JsObjectBuilder columnBuilder = new JsObjectBuilder(); // 列的禁用会反映到每个单元格上,而不是在列头 OB.RemoveProperty("disabled"); if (this is RowNumberField) { OB.AddProperty("xtype", "rownumberer"); } OB.AddProperty("text", GetHeaderValue()); if (!String.IsNullOrEmpty(HeaderToolTip)) { OB.AddProperty("tooltip", HeaderToolTip); OB.AddProperty("tooltipType", ToolTipTypeName.GetName(HeaderToolTipType)); } if (Hidden) { OB.AddProperty("hidden", true); } if (!String.IsNullOrEmpty(InnerCls)) { OB.AddProperty("innerCls", InnerCls); } if (Grid.AllowSorting) { if (String.IsNullOrEmpty(SortField)) { OB.AddProperty("sortable", false); } else { OB.AddProperty("sortable", true); } } else { OB.AddProperty("sortable", false); } // 允许列锁定 if (Grid.AllowColumnLocking) { if (EnableLock) { OB.AddProperty("lockable", true); } else { OB.AddProperty("lockable", false); } if (Locked) { OB.AddProperty("lockable", true); OB.AddProperty("locked", true); } } if (PersistState) { OB.AddProperty("f_persistState", true); OB.AddProperty("f_persistStateType", "checkbox"); } //If not specified, the column's index is used as an index into the Record's data Array. OB.AddProperty("dataIndex", ColumnID); OB.AddProperty("id", ColumnID); // 服务器端使用的ColumnIndex OB.AddProperty("f_columnIndex", ColumnIndex); /* * if (TextAlign != TextAlign.Left) * { * OB.AddProperty("align", TextAlignName.GetName(TextAlign)); * } */ if (TextAlign != null) { // 行序号列默认靠右显示;其他靠左显示;所以只要定义了 TextAlign,就输出 OB.AddProperty("align", TextAlignName.GetName(TextAlign.Value)); } if (Width != Unit.Empty) { OB.AddProperty("width", Width.Value); } else if (BoxFlex != 0) { OB.AddProperty("flex", BoxFlex); } if (MinWidth != Unit.Empty) { OB.AddProperty("minWidth", MinWidth.Value); } if (ExpandUnusedSpace) { OB.AddProperty("flex", 1); } if (Grid.EnableHeaderMenu) { if (EnableHeaderMenu) { OB.AddProperty("menuDisabled", false); } else { OB.AddProperty("menuDisabled", true); } } else { OB.AddProperty("menuDisabled", true); } if (EnableColumnHide) { OB.AddProperty("hideable", true); } else { OB.AddProperty("hideable", false); } // mod by wz //if (Grid.EnableSummary) //{ // if (this is RowNumberField) // { // // 序号列 没有合计 // } // else // { // OB.AddProperty("summaryType", String.Format("F.util.summaryType('{0}')", Grid.ClientID), true); // } //} if (this is BoundField) { if (DataType == GridColumnDataType.Default) { // do nothing } else { OB.AddProperty("xtype", GridColumnDataTypeHelper.GetName(DataType)); } } if (Grid.EnableSummary) { if (this is RowNumberField) { // 序号列 没有合计 } else { if (string.IsNullOrEmpty(SummaryType) && string.IsNullOrEmpty(SummaryRenderer)) { OB.AddProperty("summaryType", String.Format("F.util.summaryType('{0}')", Grid.ClientID), true); } else { if (!string.IsNullOrEmpty(SummaryType)) { OB.AddProperty("summaryType", SummaryType); } if (!string.IsNullOrEmpty(SummaryRenderer)) { OB.AddProperty("summaryRenderer", SummaryRenderer, true); } } } } } }
/// <summary> /// 取得单元格的数据 /// </summary> /// <param name="row"></param> /// <param name="checkState"></param> /// <returns></returns> private string GetColumnValue(GridRow row, bool checkState) { string result = String.Empty; if (!String.IsNullOrEmpty(DataField)) { string textAlignClass = String.Empty; if (TextAlign != TextAlign.Left) { textAlignClass = "box-grid-checkbox-" + TextAlignName.GetName(TextAlign); } if (RenderAsStaticField) { if (checkState) { result = "<div class=\"box-grid-static-checkbox " + textAlignClass + "\"></div>"; } else { result = "<div class=\"box-grid-static-checkbox box-grid-static-checkbox-unchecked " + textAlignClass + "\"></div>"; } } else { string paramStr = String.Format("Command${0}${1}${2}${3}", row.RowIndex, ColumnIndex, CommandName.Replace("'", "\""), CommandArgument.Replace("'", "\"")); // 延迟执行 string postBackReference = JsHelper.GetDeferScript(Grid.GetPostBackEventReference(paramStr), 0); // string onClickScript = String.Format("{0}_checkbox{1}(event,this,{2});", Grid.XID, ColumnIndex, row.RowIndex); string onClickScript = "Ext.get(this).toggleClass('box-grid-checkbox-unchecked');"; if (!ShowHeaderCheckBox && AutoPostBack) { onClickScript += postBackReference; } onClickScript += "X.util.stopEventPropagation.apply(null, arguments);"; if (checkState) { if (Enabled) { result = String.Format("<div class=\"box-grid-checkbox {0}\" onclick=\"{1}\"></div>", textAlignClass, onClickScript); } else { result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-disabled {0}\"></div>", textAlignClass); } } else { if (Enabled) { result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-unchecked {0}\" onclick=\"{1}\"></div>", textAlignClass, onClickScript); } else { result = String.Format("<div class=\"box-grid-checkbox box-grid-checkbox-disabled box-grid-checkbox-unchecked-disabled {0}\"></div>", textAlignClass); } } } } return(result); }
/// <summary> /// 渲染 HTML 之前调用(页面第一次加载或者普通回发) /// </summary> protected override void OnFirstPreRender() { base.OnFirstPreRender(); if (this is TemplateField && (this as TemplateField).RenderAsRowExpander) { // 行扩展列需要特殊处理 } else { //JsObjectBuilder columnBuilder = new JsObjectBuilder(); // 列的禁用会反映到每个单元格上,而不是在列头 OB.RemoveProperty("disabled"); if (this is RowNumberField) { OB.AddProperty("xtype", "rownumberer"); } OB.AddProperty("text", GetHeaderValue()); if (!String.IsNullOrEmpty(HeaderToolTip)) { OB.AddProperty("tooltip", HeaderToolTip); OB.AddProperty("tooltipType", ToolTipTypeName.GetName(HeaderToolTipType)); } if (Hidden) { OB.AddProperty("hidden", true); } if (!String.IsNullOrEmpty(InnerCls)) { OB.AddProperty("innerCls", InnerCls); } if (Grid.AllowSorting) { if (String.IsNullOrEmpty(SortField)) { OB.AddProperty("sortable", false); } else { OB.AddProperty("sortable", true); } } else { OB.AddProperty("sortable", false); } if (PersistState) { OB.AddProperty("f_persistState", true); OB.AddProperty("f_persistStateType", "checkbox"); } //If not specified, the column's index is used as an index into the Record's data Array. 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); } else if (BoxFlex != 0) { OB.AddProperty("flex", BoxFlex); } if (ExpandUnusedSpace) { OB.AddProperty("flex", 1); } if (Grid.EnableHeaderMenu) { if (EnableHeaderMenu) { OB.AddProperty("menuDisabled", false); } else { OB.AddProperty("menuDisabled", true); } } else { OB.AddProperty("menuDisabled", true); } if (EnableColumnHide) { OB.AddProperty("hideable", true); } else { OB.AddProperty("hideable", false); } if (Grid.EnableSummary) { if (this is RowNumberField) { // 序号列 没有合计 } else { OB.AddProperty("summaryType", String.Format("F.util.summaryType('{0}')", Grid.ClientID), true); } } } }