Grid中动态设置单元格是否可用

by RainBirda 2016.2.24 16:58
注:脚本执行有风险,对于客户正式环境请在研发指导下执行。 根据条件动态设置Grid中某一行的某个单元格不可使用,啥也不说了,直接上代码 public void AfterUIModelBinding() { this.EnableGridCell(fo); }   //Grid单元格可编辑性控制 private void EnableGridCell(ForecastOrderRecord head) { if (this.TabControl1.SelectedIndex == 0) { #region Grid行页签 UFGrid ufGrid = (UFGrid)this.DataGrid1; if (ufGrid.DataSource == null) return; System.Data.DataTable dt = ufGrid.DataSource as System.Data.DataTable; if (dt == null || dt.Rows.Count <= 0) return;   //int curIndex = this.Model.SalePlan_SalePlanPlots_SalePlanLines.PageStrategy.CurrentPageIndex; for (int i = 0; i < dt.Rows.Count; i++) { long id = long.Parse(dt.Rows[i]["ID"].ToString()); ForecastOrder_ForecastOrderLinesRecord line = this.Model.ForecastOrder_ForecastOrderLines.Records.FindValue("ID", id) as ForecastOrder_ForecastOrderLinesRecord; if (line != null) { List<string> inCol = new List<string>(); //订货客户非空,才可参照客户料号 if (this.IsNullRef(head.Customer_Customer)) { inCol.Add("CustItem"); ufGrid.SetCellDisabled(i, "CustItem"); } if (line.ItemInfo_ItemID_IsMultyUOM == false) { inCol.Add("TU"); ufGrid.SetCellDisabled(i, "TU"); }   if (line.Status == (int)ForecastOrderStatusEnumData.Closed) { for (int colIndex = 0; colIndex < this.DataGrid1.Columns.Count; colIndex++) { IUFDataGridColumn col = this.DataGrid1.Columns[colIndex]; if (col != null && col.Visible) { if (!inCol.Contains(col.UIFieldID)) { ufGrid.SetCellDisabled(i, col.UIFieldID); } } } } } } #endregion } }

RecentComments

评论 RSS

Statistics

989 篇文章
0 个单页
645558 条评论
11 次评分
209447 次访问
访问统计开始于 2019年12月15日
平均日访问 5370 次
当前 110 人在线