/// <summary> /// SmartGridView的RowDataBoundCell事件 /// </summary> /// <param name="sender"></param> /// <param name="gvtc"></param> void _sgv_RowDataBoundCell(object sender, GridViewTableCell gvtc) { if (!String.IsNullOrEmpty(this._sgv.SortExpression) && this._sgv.SmartSorting.AllowSortTip && gvtc.RowType == DataControlRowType.Header) { // 显示排序状态提示 DisplaySortTip(this._sgv.SortExpression, gvtc.TableCell); } }
/// <summary> /// RichGridView的RowDataBoundCell事件 /// </summary> /// <param name="sender"></param> /// <param name="gvtc"></param> void _sgv_RowDataBoundCell(object sender, GridViewTableCell gvtc) { TableCell tc = gvtc.TableCell; GridViewRow gvr = (GridViewRow)tc.Parent; int i = 0; // 0-既不固定行也不固定列;1-固定行或固定列;2-既固定行也固定列 // 固定行 if ( ( !String.IsNullOrEmpty(this._sgv.FixRowColumn.FixRows) && Array.Exists(this._sgv.FixRowColumn.FixRows.Split(','), delegate(string s) { return s == gvr.RowIndex.ToString(); }) ) || ( !String.IsNullOrEmpty(this._sgv.FixRowColumn.FixRowType) && Array.Exists(this._sgv.FixRowColumn.FixRowType.Split(','), delegate(string s) { return s == gvr.RowType.ToString(); }) ) || ( !String.IsNullOrEmpty(this._sgv.FixRowColumn.FixRowState) && Array.Exists(this._sgv.FixRowColumn.FixRowState.Split(','), delegate(string s) { return s == gvr.RowState.ToString(); }) ) ) { i++; Helper.Common.SetAttribute(tc, "class", "yy_sgv_fixRow", AttributeValuePosition.Last, ' '); } // 固定列 if ( !String.IsNullOrEmpty(this._sgv.FixRowColumn.FixColumns) && Array.Exists(this._sgv.FixRowColumn.FixColumns.Split(','), delegate(string s) { return s == gvtc.ColumnIndex.ToString(); }) ) { i++; Helper.Common.SetAttribute(tc, "class", "yy_sgv_fixCol", AttributeValuePosition.Last, ' '); } // 低等级的z-index if (i == 1) { Helper.Common.SetAttribute(tc, "class", "yy_sgv_fixLow", AttributeValuePosition.Last, ' '); } // 高等级的z-index else if (i == 2) { Helper.Common.SetAttribute(tc, "class", "yy_sgv_fixHigh", AttributeValuePosition.Last, ' '); } }
/// <summary> /// RowDataBoundCell /// </summary> /// <param name="sender"></param> /// <param name="gvtc"></param> void _sgv_RowDataBoundCell(object sender, GridViewTableCell gvtc) { TableCell tc = gvtc.TableCell; foreach (Control c in tc.Controls) { IButtonControl ibc = c as IButtonControl; if (ibc != null && this._sgv.BoundRowDoubleClickCommandName == ibc.CommandName) { // 响应双击事件的脚本 string js = this._sgv.Page.ClientScript.GetPostBackClientHyperlink(c, ""); GridViewRow gvr = tc.Parent as GridViewRow; Helper.Common.SetAttribute(gvr, "ondblclick", js, AttributeValuePosition.Last); _rowDoubleClickButtonUniqueIdList.Add(c.UniqueID); } } }
/// <summary> /// RowDataBoundCell /// </summary> /// <param name="sender"></param> /// <param name="gvtc"></param> void _sgv_RowDataBoundCell(object sender, GridViewTableCell gvtc) { TableCell tc = gvtc.TableCell; foreach (Control c in tc.Controls) { IButtonControl ibc = c as IButtonControl; if (ibc != null && this._sgv.BoundRowClickCommandName == ibc.CommandName) { // 300毫秒后响应单击事件的脚本(避免和双击事件冲突) string js = this._sgv.Page.ClientScript.GetPostBackClientHyperlink(c, ""); js = js.Insert(11, "setTimeout(\""); js += "\", 300)"; GridViewRow gvr = tc.Parent as GridViewRow; Helper.Common.SetAttribute(gvr, "onclick", js, AttributeValuePosition.Last); _rowClickButtonUniqueIdList.Add(c.UniqueID); } } }
/// <summary> /// RichGridView的RowDataBoundCell事件 /// </summary> /// <param name="sender"></param> /// <param name="gvtc"></param> void _sgv_RowDataBoundCell(object sender, GridViewTableCell gvtc) { TableCell tc = gvtc.TableCell; // TableCell里的每个Control foreach (Control c in tc.Controls) { // 如果控件继承自接口IButtonControl if (c is IButtonControl) { // 从用户定义的ClientButtons集合中分解出ClientButton foreach (ClientButton cb in this._sgv.ClientButtons) { // 如果在ClientButtons中绑定了该按钮的CommandName if (((IButtonControl)c).CommandName == cb.BoundCommandName) { // 替换占位符{0}-CommandArgument;{1}-Text string attributeValue = String.Format( cb.AttributeValue, ((IButtonControl)c).CommandArgument, ((IButtonControl)c).Text); // 设置按钮的客户端属性 Wgi.Web.UI.Controls.Helper.Common.SetAttribute( (IAttributeAccessor)c, cb.AttributeKey, attributeValue, cb.Position); break; } } } } }