1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- namespace EMIS.Web.Controls
- {
- public class UserRoleColumn : DataGridColumn
- {
- public string FieldName { get; set; }
- protected override IDictionary<string, string> GetOptionsList()
- {
- var baseOptions = base.GetOptionsList();
- baseOptions.Add("columnType", "'userRole'");
- baseOptions.Add("field", string.Format("'{0}'", string.IsNullOrEmpty(FieldName) ? "emptyField_" + Guid.NewGuid().ToString().Substring(0, 6) : FieldName.Trim()));
- baseOptions.Add("formatter", "");
- //*****************************************
- //Modif : by 劳炳辉 2013.4.26
- //修改数据格式化函数,使DataGrid支持多层对象数据[father:[name:"父亲",son:[name:"儿子"]]]的读取
- //*****************Start*******************
- 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 '<a href=\"javascript:EMISFunction.UserRole.Popup('{0}')\">点击查看用户类型</a>'; ",
- val) +
- "}";
- //*****************End*******************
- #endregion
- //*****************End*******************
- return baseOptions;
- }
- }
- }
|