/// <summary> /// 渲染 HTML 之前调用(页面第一次加载或者普通回发) /// </summary> protected override void OnFirstPreRender() { base.OnFirstPreRender(); #region Check Parent Accordion parentControl = Parent as Accordion; if (parentControl == null) { throw new Exception("AccordionPane must inside the control Accordion!"); } if (parentControl.AutoPostBack) { OB.Listeners.AddProperty("expand", JsHelper.GetFunction(parentControl.GetPostBackEventReference("PaneIndexChanged")), true); } #endregion //#region AutoHeight //// 如果要充满整个Accordion,则设置每个AccordionPanel的AutoHeight=false //if (parentControl.EnableFill) //{ // OB.AddProperty("autoHeight", false); //} //#endregion string renderScript = String.Empty; #region oldcode //// 如果启用高亮显示选中的,则在每个AccordionPanel的折叠展开时都要改变高亮选中的状态 //if (EnableLargeHeader && EnableHightlight) //{ // renderScript += String.Format("{0}.header.addClassOnOver('{1}');", XID, ACCORDION_HEADER_HOVER); // // 如果这个AccordionPanel需要高亮显示 // if (parentControl.ActiveIndex >= 0 && parentControl.ActiveIndex < parentControl.Panes.Count) // { // if (parentControl.Panes[parentControl.ActiveIndex] == this) // { // //OB.AddProperty(OptionName.Cls, ACCORDION_BIG_HEADER_SELECT_CLASS); // renderScript += String.Format("{0}.header.addClass('{1}');", XID, ACCORDION_HEADER_SELECT); // } // } // OB.Listeners.RemoveProperty("collapse"); // OB.Listeners.RemoveProperty("expand"); // OB.Listeners.AddProperty("collapse", String.Format("function(panel){{Ext.get('{0}').dom.value=true;X.{1}.header.removeClass('{2}');}}", CollapsedHiddenFieldID, XID, ACCORDION_HEADER_SELECT), true); // OB.Listeners.AddProperty("expand", String.Format("function(panel){{Ext.get('{0}').dom.value=false;X.{1}.header.addClass('{2}');}}", CollapsedHiddenFieldID, XID, ACCORDION_HEADER_SELECT), true); //} #endregion #region Links //if (Links.Count > 0) //{ // OB.RemoveProperty("items"); // StringBuilder sb = new StringBuilder(); // sb.Append("<ul class=\"f-accrodion-link-ul\">"); // foreach (AccordionLink link in Links) // { // #region li // HtmlNodeBuilder nb = new HtmlNodeBuilder("a"); // nb.SetProperty("id", link.ClientID); // if (!String.IsNullOrEmpty(link.OnClientClick)) // { // nb.SetProperty("onclick", String.Format("javascript:{0}", link.OnClientClick)); // } // if (!String.IsNullOrEmpty(link.NavigateUrl)) // { // nb.SetProperty("href", ResolveUrl(link.NavigateUrl)); // if (!String.IsNullOrEmpty(link.Target)) // { // nb.SetProperty("target", link.Target); // } // } // nb.SetProperty("style", "display:block;cursor:pointer;"); // string content = String.Empty; // if (!String.IsNullOrEmpty(link.IconUrl)) // { // content += String.Format("<img src=\"{0}\" align=\"bottom\" alt=\"\" />", ResolveUrl(link.IconUrl)); // } // content += " " + link.Text; // nb.InnerProperty = content; // #endregion // sb.AppendFormat("<li {1}>{0}</li>", nb.ToString(), link.Selected ? "class=\"f-accrodion-link-select\"" : ""); // } // sb.Append("</ul>"); // OB.AddProperty("html", sb.ToString()); // // 注册所有链接的脚本 // // 所有的li,鼠标移动上去是一种样式,鼠标移开又是另外一种样式 // string hoverScript = "ele = Ext.get(ele);"; // hoverScript += "ele.on('mouseover',function(){Ext.get(this.findParentNode('li')).addClass('box-accrodion-link-hover');},ele);"; // hoverScript += "ele.on('mouseout',function(){Ext.get(this.findParentNode('li')).removeClass('box-accrodion-link-hover');},ele);"; // //string clickScript = String.Empty; // //clickScript += String.Format("Ext.each(X.{0}.el.query('ul.box-accrodion-link-ul li'),function(ele){{Ext.get(ele).removeClass('box-accrodion-link-select');}});", parentControl.ClientJavascriptID); // //clickScript += "Ext.get('{0}').addClass('box-accrodion-link-select');"; // string clickScript = String.Format("function(){{X.{0}.box_active(ele.id);}}", parentControl.XID); // hoverScript += "ele.on('click'," + clickScript + ");"; // renderScript += String.Format("Ext.each(X.{0}.el.query('ul.box-accrodion-link-ul li a'),function(ele){{{1}}});", XID, hoverScript); //} #endregion if (!String.IsNullOrEmpty(renderScript)) { renderScript = JsHelper.GetDeferScript(renderScript, 100); OB.Listeners.AddProperty("render", JsHelper.GetFunction(renderScript), true); } string jsContent = String.Format("var {0}=Ext.create('Ext.panel.Panel',{1});", XID, OB.ToString()); AddStartupScript(jsContent); }
/// <summary> /// 取得单元格的数据 /// </summary> /// <param name="row"></param> /// <param name="checkState"></param> /// <returns></returns> private string GetColumnValue(GridRow row, bool checkState) { string result = String.Empty; string emptyImageUrl = Grid.ResolveUrl(ResourceHelper.GetEmptyImageUrl()); if (!String.IsNullOrEmpty(DataField)) { //string textAlignClass = String.Empty; //if (TextAlign != TextAlign.Left) //{ // textAlignClass = "align-" + TextAlignName.GetName(TextAlign); //} if (RenderAsStaticField) { if (checkState) { result = String.Format("<img class=\"f-grid-static-checkbox\" src=\"{0}\"/>", emptyImageUrl); } else { result = String.Format("<img class=\"f-grid-static-checkbox unchecked\" src=\"{0}\"/>", emptyImageUrl); } } 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('unchecked');"; string onClickScript = "F.toggle(this,'unchecked');"; if (!ShowHeaderCheckBox && AutoPostBack) { onClickScript += postBackReference; } //onClickScript += "F.stop();"; if (checkState) { if (Enabled) { result = String.Format("<img class=\"f-grid-checkbox\" src=\"{0}\" onclick=\"{1}\"/>", emptyImageUrl, onClickScript); } else { result = String.Format("<img class=\"f-grid-checkbox disabled\" src=\"{0}\"/>", emptyImageUrl); } } else { if (Enabled) { result = String.Format("<img class=\"f-grid-checkbox unchecked\" src=\"{0}\" onclick=\"{1}\"/>", emptyImageUrl, onClickScript); } else { result = String.Format("<img class=\"f-grid-checkbox unchecked disabled\" src=\"{0}\"/>", emptyImageUrl); } } } } return(result); }
/// <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); }
internal override string GetColumnValue(GridRow row) { //string result = String.Empty; #region DataTextField string text = String.Empty; if (!String.IsNullOrEmpty(DataTextField)) { object value = row.GetPropertyValue(DataTextField); if (!String.IsNullOrEmpty(DataTextFormatString)) { text = String.Format(DataTextFormatString, value); if (HtmlEncodeFormatString) { text = HttpUtility.HtmlEncode(text); } } else { text = value.ToString(); if (HtmlEncode) { text = HttpUtility.HtmlEncode(text); } } } else { text = Text; } #endregion HtmlNodeBuilder nb; #region Enabled nb = new HtmlNodeBuilder("a"); if (Enabled) { nb.SetProperty("href", "javascript:;"); // click string paramStr = String.Format("Command${0}${1}${2}${3}", row.RowIndex, ColumnIndex, CommandName.Replace("'", "\""), CommandArgument.Replace("'", "\"")); string postBackReference = Grid.GetPostBackEventReference(paramStr); string clientScript = Button.ResolveClientScript(ValidateForms, ValidateTarget, ValidateMessageBox, EnablePostBack, postBackReference, ConfirmText, ConfirmTitle, ConfirmIcon, ConfirmTarget, OnClientClick, String.Empty); clientScript = JsHelper.GetDeferScript(clientScript, 0) + "X.util.stopEventPropagation.apply(null, arguments);"; nb.SetProperty("onclick", clientScript); //result = nb.ToString(); } else { nb.SetProperty("class", "x-item-disabled"); nb.SetProperty("disabled", "disabled"); //nb = new HtmlNodeBuilder("span"); //nb.SetProperty("class", "gray"); //nb.InnerProperty = text; //result = String.Format("<span class=\"gray\">{0}</span>", text); } nb.InnerProperty = text; #endregion string tooltip = GetTooltipString(row); #region Icon IconUrl string resolvedIconUrl = IconHelper.GetResolvedIconUrl(Icon, IconUrl); if (!String.IsNullOrEmpty(resolvedIconUrl)) { nb.InnerProperty = String.Format("<img src=\"{0}\" {1} />", resolvedIconUrl, tooltip) + nb.InnerProperty; } #endregion //string result = nb.ToString(); //#region Tooltip //if (!String.IsNullOrEmpty(tooltip)) //{ // if (result.StartsWith("<a ")) // { // result = result.ToString().Insert(2, tooltip); // } // else if (result.StartsWith("<span ")) // { // result = result.ToString().Insert(5, tooltip); // } //} //#endregion //return result; string result = nb.ToString(); if (!String.IsNullOrEmpty(tooltip)) { result = result.ToString().Insert("<a".Length, tooltip); } return(result); }