/// <summary> /// 设置checkbox状态句柄 /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void DeluxeGrid_SetCheckBoxStatusHandler(object sender, DeluxeGridCheckBoxEventArgs args) { if (SetCheckBoxStatusHandler != null) SetCheckBoxStatusHandler(sender, args); }
/// <summary> /// /// </summary> /// <param name="e"></param> protected override void OnRowDataBound(GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: { for (int i = 0; i < e.Row.Cells.Count; i++) { TableCell cell = e.Row.Cells[i]; if (cell.Controls.Count == 0) { cell.Text = Translator.Translate(Category, cell.Text); } else { if (cell.Controls[0] is IButtonControl) { IButtonControl button = (IButtonControl)cell.Controls[0]; button.Text = Translator.Translate(Category, button.Text); } } //cell.CssClass = this.HeaderRowCssClass; } foreach (DataControlField column in this.Columns) { //column.HeaderText = Translator.Translate(Category, column.HeaderText); } if (this.ShowCheckBoxes) { if (this.CheckBoxPosition == RowPosition.Left) e.Row.Cells[0].CssClass = CheckBoxTemplateHeaderStyle.CssClass; else e.Row.Cells[e.Row.Cells.Count - 1].CssClass = CheckBoxTemplateHeaderStyle.CssClass; } } break; case DataControlRowType.EmptyDataRow: { if (e.Row.Cells.Count > 0) { string originalText = e.Row.Cells[0].Text; string targetText = originalText.Trim('\t', '\r', '\n'); e.Row.Cells[0].Text = HttpUtility.HtmlEncode(Translator.Translate(this.Category, targetText)); } } break; } if (this.ShowCheckBoxes) { if (e.Row.RowType == DataControlRowType.Header) CheckAllID = e.Row.ClientID + "_checkall"; if (e.Row.RowType == DataControlRowType.DataRow) { string itemsValue = ""; InputButton chk = ((InputButton)e.Row.FindControl("checkitem")); if (e.Row.DataItem.GetType().FullName == "System.Data.DataRowView") { if (chk != null) { itemsValue = ((System.Data.DataRowView)(e.Row.DataItem)).Row[DataKeyNames[0]].ToString(); chk.Value = itemsValue; DeluxeGridCheckBoxEventArgs args = new DeluxeGridCheckBoxEventArgs(); args.CheckBoxValue = itemsValue; args.RowEventArgs = e; DeluxeGrid_SetCheckBoxStatusHandler(e.Row.DataItem, args); chk.Visible = args.CheckBoxVisible; } } else { if (chk != null) { itemsValue = e.Row.DataItem.GetType().GetProperty(DataKeyNames[0]).GetGetMethod().Invoke(e.Row.DataItem, new Object[] { }).ToString(); chk.Value = itemsValue; DeluxeGridCheckBoxEventArgs args = new DeluxeGridCheckBoxEventArgs(); args.CheckBoxValue = itemsValue; args.RowEventArgs = e; DeluxeGrid_SetCheckBoxStatusHandler(e.Row.DataItem, args); chk.Visible = args.CheckBoxVisible; } } foreach (string keys in SelectedKeys) { if (itemsValue == keys && chk != null) { chk.Checked = true; this.selectedCount++; } } } } if (e.Row.RowType == DataControlRowType.DataRow) if (this.ExportingDeluxeGrid) for (int i = 0; i < e.Row.Cells.Count; i++) { if (this.ShowCheckBoxes && i == 0 && this.CheckBoxPosition == RowPosition.Left) { e.Row.Cells[i].CssClass = "col-chekbox"; } else if (this.ShowCheckBoxes && i == e.Row.Cells.Count - 1 && this.CheckBoxPosition == RowPosition.Right) { e.Row.Cells[i].CssClass = "col-chekbox"; } else { if (this.Columns[i].ItemStyle.CssClass.IsNullOrEmpty()) { e.Row.Cells[i].CssClass = this.RowLineCssClass; } e.Row.Cells[i].Style.Add("word-break", "break-all"); } } else for (int i = 0; i < e.Row.Cells.Count; i++) { if (this.ShowCheckBoxes && i == 0 && this.CheckBoxPosition == RowPosition.Left) { e.Row.Cells[i].CssClass = "col-chekbox"; } else if (this.ShowCheckBoxes && i == e.Row.Cells.Count - 1 && this.CheckBoxPosition == RowPosition.Right) { e.Row.Cells[i].CssClass = "col-chekbox"; } else { if (this.Columns[i].ItemStyle.CssClass.IsNullOrEmpty()) { e.Row.Cells[i].CssClass = this.RowLineCssClass; } e.Row.Cells[i].Style.Add("word-wrap", "break-word"); } } base.OnRowDataBound(e); }