ApproveStatusColumn.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Bowin.Web.Controls.Mvc;
  6. namespace EMIS.Web.Controls
  7. {
  8. public class ApproveStatusColumn : DataGridColumn
  9. {
  10. public string FieldName { get; set; }
  11. public string TableName { get; set; }
  12. public string IDFieldName { get; set; }
  13. protected override IDictionary<string, string> GetOptionsList()
  14. {
  15. var baseOptions = base.GetOptionsList();
  16. baseOptions.Add("columnType", "'approveStatus'");
  17. baseOptions.Add("field", string.Format("'{0}'", string.IsNullOrEmpty(FieldName) ? "emptyField_" + Guid.NewGuid().ToString().Substring(0, 6) : FieldName.Trim()));
  18. baseOptions.Add("formatter", "");
  19. string idVal = "row['" + IDFieldName + "']";
  20. if (!string.IsNullOrEmpty(IDFieldName) && IDFieldName.IndexOf('.') > -1)
  21. idVal = "(new Object(row['" + IDFieldName.Trim().Split('.')[0].Trim() + "']))." + IDFieldName.Trim().Substring(IDFieldName.IndexOf('.') + 1).Trim();
  22. string val = "value";
  23. if (!string.IsNullOrEmpty(FieldName) && FieldName.IndexOf('.') > -1)
  24. val = "(new Object(row['" + FieldName.Trim().Split('.')[0].Trim() + "']))." + FieldName.Trim().Substring(FieldName.IndexOf('.') + 1).Trim();
  25. #region 增强Formatter参数使用便利性
  26. baseOptions["formatter"] =
  27. "function(value,row,index){ " +
  28. string.Format(@"return '<a href=&quot;javascript:EMISFunction.ApproveStatus.Popup(\'" + TableName + @"\', \''+{0}+'\')&quot;>'+{1}+'</a>'; ",
  29. idVal, val) +
  30. "}";
  31. //*****************End*******************
  32. #endregion
  33. //*****************End*******************
  34. return baseOptions;
  35. }
  36. }
  37. }