/// <summary> /// 添加自定义列到Grid的Column中 /// </summary> /// <param name="column"></param> void AddToGridColumn(GridColumn column) { FieldType type = column.type; switch (type) { case FieldType.LineNumberField: LineNumberField lnf = new LineNumberField(); lnf.IsContinuousArrange = true; lnf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; lnf.HeaderStyle.Width = column.unit; lnf.ItemStyle.Width = column.unit; lnf.ItemStyle.HorizontalAlign = HorizontalAlign.Center; this.Columns.Add(lnf); break; case FieldType.BoundField: BoundField bf = new BoundField(); bf.HeaderText = column.headerName; bf.HeaderStyle.Width = column.unit; bf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; bf.DataField = column.fieldName; bf.ItemStyle.Width = column.unit; bf.ItemStyle.HorizontalAlign = column.hAlign; bf.SortExpression = column.fieldName; this.Columns.Add(bf); break; case FieldType.ButtonField: ButtonField btn = new ButtonField(); btn.HeaderText = column.headerName; btn.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; btn.HeaderStyle.Width = column.unit; btn.HeaderStyle.Wrap = false; btn.ButtonType = column.button; btn.ItemStyle.Width = column.unit; btn.ItemStyle.HorizontalAlign = column.hAlign; if (btn.ButtonType == ButtonType.Image) { btn.ImageUrl = column.fieldName; } else { btn.Text = column.fieldName; } btn.CommandName = column.commandName; this.Columns.Add(btn); break; case FieldType.RadioButtonField: RadioButtonField rbf = new RadioButtonField(); rbf.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; rbf.HeaderStyle.Width = column.unit; rbf.ItemStyle.Width = column.unit; this.Columns.Add(rbf); break; case FieldType.CheckBoxExField: CheckBoxExField cbef = new CheckBoxExField(); cbef.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; cbef.HeaderStyle.Width = column.unit; cbef.ItemStyle.Width = column.unit; cbef.CheckedValue = "1"; this.Columns.Add(cbef); break; case FieldType.CheckBoxField: CheckBoxField cbf = new CheckBoxField(); cbf.HeaderText = column.headerName; cbf.DataField = column.fieldName; cbf.ItemStyle.HorizontalAlign = column.hAlign; this.Columns.Add(cbf); break; case FieldType.HyperLinkField: HyperLinkField hf = new HyperLinkField(); //hf.Text = column.headerName; hf.HeaderText = column.headerName; if (string.IsNullOrEmpty(column.text)) { hf.DataTextField = column.fieldName; } else { hf.Text = column.text; } hf.ItemStyle.HorizontalAlign = column.hAlign; hf.Target = column.target; hf.DataNavigateUrlFields = column.dataNavigateUrlFields; hf.DataNavigateUrlFormatString = column.dataNavigateUrlFormatString; this.Columns.Add(hf); break; case FieldType.LinkButtonTemplate: LinkButtonTemplate lbt = column._linkButtonTemplate; TemplateField templateLinkButtonField = new TemplateField(); templateLinkButtonField.ItemTemplate = lbt; templateLinkButtonField.HeaderText = column.headerName; templateLinkButtonField.HeaderStyle.Width = templateLinkButtonField.ItemStyle.Width = column.unit; templateLinkButtonField.HeaderStyle.HorizontalAlign = templateLinkButtonField.ItemStyle.HorizontalAlign = column.hAlign; this.Columns.Add(templateLinkButtonField); break; case FieldType.DialogButtonTemplate: DialogButtonTemplate dialogButtonTemplate = column._dialogButtonTemplate; TemplateField templateField = new TemplateField(); templateField.ItemTemplate = dialogButtonTemplate; templateField.HeaderText = column.headerName; templateField.HeaderStyle.Width = templateField.ItemStyle.Width = column.unit; templateField.HeaderStyle.HorizontalAlign = templateField.ItemStyle.HorizontalAlign = column.hAlign; this.Columns.Add(templateField); break; case FieldType.TextBoxTemplate: TextBoxTemplate tb = column._textBoxTemplate; TemplateField ttb = new TemplateField(); ttb.ItemTemplate = tb; ttb.HeaderText = column.headerName; ttb.HeaderStyle.Width = ttb.ItemStyle.Width = column.unit; ttb.HeaderStyle.HorizontalAlign = ttb.ItemStyle.HorizontalAlign = column.hAlign; this.Columns.Add(ttb); break; case FieldType.ButtonTemplate: ButtonTemplate bt = column._buttonTemplate; TemplateField templateButtonField = new TemplateField(); templateButtonField.ItemTemplate = bt; templateButtonField.HeaderText = column.headerName; templateButtonField.HeaderStyle.Width = templateButtonField.ItemStyle.Width = column.unit; templateButtonField.HeaderStyle.HorizontalAlign = templateButtonField.ItemStyle.HorizontalAlign = column.hAlign; this.Columns.Add(templateButtonField); break; default: if (column._dataControlField != null) { this.Columns.Add(column._dataControlField); } break; } }
public void AddColumn(DataControlField controlField) { GridColumn column = new GridColumn(controlField); columns.Add(column); AddToGridColumn(column); }
public void AddHyperLinkColumn(string headerName, string fieldName, string text, HorizontalAlign hAlign, string target, string[] dataNavigateUrlFields, string dataNavigateUrlFormatString) { if (columns == null) columns = new List<GridColumn>(); GridColumn column = new GridColumn(); column.type = FieldType.HyperLinkField; column.headerName = headerName; column.text = text; column.fieldName = fieldName; column.hAlign = hAlign; column.target = target; column.dataNavigateUrlFields = dataNavigateUrlFields; column.dataNavigateUrlFormatString = dataNavigateUrlFormatString; columns.Add(column); AddToGridColumn(column); }
public void AddColumn(string headerName, IDictionary<string, string> dicFieldName, HorizontalAlign hAlign, int pixel, ButtonType type) { ButtonTemplate buttonTemplate = new ButtonTemplate(dicFieldName); GridColumn column = new GridColumn(buttonTemplate); column.headerName = headerName; column.hAlign = HorizontalAlign.Center; column.unit = Unit.Pixel(pixel); column.type = FieldType.ButtonTemplate; columns.Add(column); AddToGridColumn(column); }
public void AddColumn(string headerName, IDictionary<string, string> dicFieldName, HorizontalAlign hAlign, Unit unit) { LinkButtonTemplate linkButtonTemplate = new LinkButtonTemplate(dicFieldName); GridColumn column = new GridColumn(linkButtonTemplate); column.headerName = headerName; column.hAlign = HorizontalAlign.Center; column.unit = unit; column.type = FieldType.LinkButtonTemplate; columns.Add(column); AddToGridColumn(column); }
public void AddColumn(string headerName, IDictionary<string, string> dataField, string dialogTitle, string dialogUrl, string closedCallBack, int dialogWidth, int dialogHeight, string imageUrl) { if (columns == null) columns = new List<GridColumn>(); DialogButtonTemplate dialogButtonTemplate = new DialogButtonTemplate(dataField); dialogButtonTemplate.DialogWidth = dialogWidth; dialogButtonTemplate.DialogHeight = dialogHeight; dialogButtonTemplate.DialogTitle = dialogTitle; dialogButtonTemplate.DialogURL = dialogUrl; dialogButtonTemplate.ClosedCallBack = closedCallBack; dialogButtonTemplate.ImageUrl = imageUrl; GridColumn column = new GridColumn(dialogButtonTemplate); column.unit = Unit.Pixel(GridConfig.BtnLength); column.hAlign = HorizontalAlign.Center; column.headerName = headerName; column.type = FieldType.DialogButtonTemplate; columns.Add(column); AddToGridColumn(column); }
/// <summary> /// 增加ButtonField /// </summary> /// <param name="headerName">列标题</param> /// <param name="fieldName">按钮名称或者图片按钮路径</param> /// <param name="buttonLength"></param> /// <param name="button">按钮类型</param> /// <param name="commandName">命令名称</param> /// <param name="hAlign"></param> public void AddColumn(string headerName, string fieldName, int buttonLength, ButtonType button, string commandName, HorizontalAlign hAlign) { if (columns == null) columns = new List<GridColumn>(); string headerNameTemp = headerName; GridColumn column = new GridColumn(headerNameTemp, fieldName, Unit.Pixel(buttonLength), FieldType.ButtonField, button, commandName, hAlign); columns.Add(column); AddToGridColumn(column); }
/// <summary> /// 增加BoundField /// </summary> /// <param name="headerName">列标题</param> /// <param name="fieldName">列名</param> /// <param name="unit">宽度</param> /// <param name="type">field类型</param> /// <param name="button">button类型</param> /// <param name="commandName"></param> /// <param name="hAlign">水平对齐</param> public void AddColumn(string headerName, string fieldName, Unit unit, FieldType type, ButtonType button, string commandName, HorizontalAlign hAlign) { if (columns == null) columns = new List<GridColumn>(); string headerNameTemp = headerName; GridColumn column = new GridColumn(headerNameTemp, fieldName, unit, type, button, commandName, hAlign); columns.Add(column); AddToGridColumn(column); }