当第一个或者第二个combobox的值改变时js调用的方法。
- protected void FpSpread1_OnButtonCommand(object sender, SpreadCommandEventArgs e)
- {
- FpSpread1.SaveChanges();
- switch (e.CommandName)
- {
- case "DivisionChanged":
- Point cellDivision = (Point)e.CommandArgument;
- int divisionId = Convert.ToInt32(this.FpSpread1.ActiveSheetView
- .Cells[(cellDivision.X + this.FpSpread1.CurrentPage * 15), cellDivision.Y].Value.ToString());
- DataTable dt = (DataTable)Session["DEPARTMENT"];
- DataView office = dt.DefaultView;
- office.RowFilter = string.Format("HEAD_OFFICE_CODE = {0}",divisionId);
- DataTable resultOfficeDt = office.ToTable("DEPARTMENT", true, "OFFICE_CODE", "OFFICE_NAME");
- DataTable resultGroupDt = office.ToTable("DEPARTMENT", true, "GROUP_CODE", "GROUP_NAME");
- ComboBoxCellType cobDepartment = new ComboBoxCellType();
- cobDepartment.ShowButton = true;
- cobDepartment.DataSource = resultOfficeDt;
- cobDepartment.DataTextField = "OFFICE_NAME";
- cobDepartment.DataValueField = "OFFICE_CODE";
- cobDepartment.UseValue = true;
- cobDepartment.OnClientChanged = "return DepartmentChanged();";
- FpSpread1.ActiveSheetView
- .Cells[(cellDivision.X + this.FpSpread1.CurrentPage * 15), cellDivision.Y + 1].CellType = cobDepartment;
- ComboBoxCellType cobGroup = new ComboBoxCellType();
- cobGroup.ShowButton = true;
- cobGroup.UseValue = true;
- cobGroup.DataSource = resultGroupDt;
- cobGroup.DataTextField = "GROUP_NAME";
- cobGroup.DataValueField = "GROUP_CODE";
- FpSpread1.ActiveSheetView
- .Cells[(cellDivision.X + this.FpSpread1.CurrentPage * 15), cellDivision.Y + 2].CellType = cobGroup;
- break;
- case "DepartmentChanged":
- Point cellDepart = (Point)e.CommandArgument;
- int divisionGetId = Convert.ToInt32(this.FpSpread1.ActiveSheetView
- .Cells[(cellDepart.X + this.FpSpread1.CurrentPage * 15), cellDepart.Y - 1].Value.ToString());
- int departGetId = Convert.ToInt32(this.FpSpread1.ActiveSheetView
- .Cells[(cellDepart.X + this.FpSpread1.CurrentPage * 15), cellDepart.Y].Value.ToString());
- DataTable dtDepart = (DataTable)Session["DEPARTMENT"];
- DataView group = dtDepart.DefaultView;
- group.RowFilter = string.Format("HEAD_OFFICE_CODE = {0} AND OFFICE_CODE = {1}", divisionGetId, departGetId);
- ComboBoxCellType comGroup = new ComboBoxCellType();
- comGroup.ShowButton = true;
- comGroup.UseValue = true;
- comGroup.DataSource = dtDepart;
- comGroup.DataTextField = "GROUP_NAME";
- comGroup.DataValueField = "GROUP_CODE";
- FpSpread1.ActiveSheetView
- .Cells[(cellDepart.X + this.FpSpread1.CurrentPage * 15), cellDepart.Y + 1].CellType = comGroup;
- break;
- default:
- break;
- }
- }
复制代码 |