using System; using System.Collections.Generic; using System.Linq; using System.Web; using Bowin.Web.Controls.Mvc; namespace EMIS.Web.Controls { public class ApproveStatusColumn : DataGridColumn { public string FieldName { get; set; } public string TableName { get; set; } public string IDFieldName { get; set; } protected override IDictionary GetOptionsList() { var baseOptions = base.GetOptionsList(); baseOptions.Add("columnType", "'approveStatus'"); baseOptions.Add("field", string.Format("'{0}'", string.IsNullOrEmpty(FieldName) ? "emptyField_" + Guid.NewGuid().ToString().Substring(0, 6) : FieldName.Trim())); baseOptions.Add("formatter", ""); string idVal = "row['" + IDFieldName + "']"; if (!string.IsNullOrEmpty(IDFieldName) && IDFieldName.IndexOf('.') > -1) idVal = "(new Object(row['" + IDFieldName.Trim().Split('.')[0].Trim() + "']))." + IDFieldName.Trim().Substring(IDFieldName.IndexOf('.') + 1).Trim(); string val = "value"; if (!string.IsNullOrEmpty(FieldName) && FieldName.IndexOf('.') > -1) val = "(new Object(row['" + FieldName.Trim().Split('.')[0].Trim() + "']))." + FieldName.Trim().Substring(FieldName.IndexOf('.') + 1).Trim(); #region 增强Formatter参数使用便利性 baseOptions["formatter"] = "function(value,row,index){ " + string.Format(@"return ''+{1}+''; ", idVal, val) + "}"; //*****************End******************* #endregion //*****************End******************* return baseOptions; } } }