阅读:1962
回复:4
|
子表动态添加数据项
前端代码:
<SheetControls:SheetSubTable ID="SheetSubTable_ATLECNDispo" runat="server" DataField="ATLECNDispo" OnEditorInitializing="SheetSubTable_ATLECNDispo_EditorInitializing" OnEditorSaving="SheetSubTable_ATLECNDispo_EditorSaving" OnEditorLoading="SheetSubTable_ATLECNDispo_EditorLoding" /> SheetSubTable_ATLECNDispo_EditorInitializing(添加的事件) 后台代码 protected void SheetSubTable_ATLECNDispo_EditorInitializing(object sender, OThinker.H3.WorkSheet.EditorInitializingEventArgs e) { DropDownList list = new DropDownList(); list.Items.Add("已下采购订单给供应商中"); list.Items.Add("库存"); list.Items.Add("产线中"); list.Items.Add("成品"); list.Items.Add("已经出货"); e.Control = list; //如何添加到 SheetSubTable_ATLECNDispo ? } 有在后台代码执行, 但是数据项没有对应的添加上去, |
1楼#
发布于:2019-01-25 09:31
你这个应该是8.2版本的代码吧,找了一个例子,参考一下
protected void tab_BOMProductDetail_EditorLoading(object sender, EditorLoadingEventArgs e) { var cell = e.Control as TableCell; if (Enviroment.ActivityTemplate != null) { if (Enviroment.ActivityTemplate.DisplayName == "提交BOM单") { if (e.CurrentRow.RowType == DataControlRowType.DataRow) { if (e.ColumnName == "新品种信息") { var cbx = new CheckBox(); cbx.Attributes.Add("onclick", "erpchange(this);"); bool result = false; Boolean.TryParse(e.Value.ToString(), out result); cbx.Checked = result; cell.Controls.Add(cbx); e.Set = true; } if (e.ColumnName == "品名") { var txtproduct = new SheetTextBox(); txtproduct.ID = "txtname"; txtproduct.Attributes.Add("style", "width:90%"); txtproduct.Text = e.Value.ToString(); txtproduct.Attributes.Add("lang", "requiredfield"); //txtproduct.Attributes.Add("onclick", " $.Geterppacking(this, 'Geterppacking');"); cell.Controls.Add(txtproduct); e.Set = true; } if (e.ColumnName == "ERP产品编码") { var dv = e.CurrentRow.DataItem as DataRowView; string ischeck = dv["新品种信息"].ToString(); var txtproduct = new SheetTextBox(); txtproduct.ID = "txtcode"; txtproduct.Text = e.Value.ToString(); txtproduct.Attributes.Add("style", "width:90%"); if (ischeck != "True") { txtproduct.Attributes.Add("lang", "requiredfield"); } txtproduct.Attributes.Add("onclick", " $.Geterppacking(this, 'Geterpproduct');"); cell.Controls.Add(txtproduct); e.Set = true; } if (e.ColumnName == "剂型") { var drptype = new DropDownList(); drptype.Items.Add(new ListItem { Value = "软糖", Text = "软糖" }); drptype.Items.Add(new ListItem { Value = "固体制剂", Text = "固体制剂" }); drptype.Items.Add(new ListItem { Value = "软胶囊", Text = "软胶囊" }); drptype.Items.Add(new ListItem { Value = "口服液", Text = "口服液" }); drptype.Items.Add(new ListItem { Value = "化妆品", Text = "化妆品" }); drptype.SelectedValue = e.Value.ToString(); cell.Controls.Add(drptype); e.Set = true; } } } } //ScriptManager.RegisterStartupScript(UpdatePanel1, this.Page.GetType(), "", "loadchange();", true); } |
|
2楼#
发布于:2019-01-26 11:03
武汉技术支持团队:你这个应该是8.2版本的代码吧,找了一个例子,参考一下protected void SheetSubTable_ATLECNDispo_EditorInitializing(object sender, OThinker.H3.WorkSheet.EditorInitializingEventArgs e) { var cell = e.Control as TableCell; if (e.ColumnName.ToUpper() == "MATERIAL_STATUS") { DropDownList list = new DropDownList(); /* list.Items.Add("ON ORDER"); list.Items.Add("IN STORE"); list.Items.Add("WORKING PROCESS"); list.Items.Add("FINISHED GOODS"); list.Items.Add("IN FIELD"); */ //list.Items.Add("已下采购订单给供应商中"); //list.Items.Add("库存"); //list.Items.Add("产线中"); //list.Items.Add("成品"); //list.Items.Add("已经出货"); //e.Control = list; //数据绑定不了,用下面这个方法 list.Items.Add(new ListItem { Value = "已下采购订单给供应商中", Text = "已下采购订单给供应商中" }); list.Items.Add(new ListItem { Value = "库存", Text = "库存" }); list.Items.Add(new ListItem { Value = "产线中", Text = "产线中" }); list.Items.Add(new ListItem { Value = "成品", Text = "成品" }); list.Items.Add(new ListItem { Value = "已经出货", Text = "已经出货" }); cell.Controls.Add(list); e.Set = true; } 我改了下,最后的这句 e.Set = true; 提示错误 Set是一个“方法组” 无法为它赋值 |
|
3楼#
发布于:2019-01-29 09:41
if (e.CurrentRow.RowType == DataControlRowType.DataRow)
{ } 加上这个判断试试 |
|