12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using EMISOnline.ViewModel;
- using Bowin.Common.JSON;
- using Bowin.Web.Controls.Mvc;
- using EMISOnline.Utility;
- namespace EMISOnline.Web.Controls
- {
- public class DictionaryDropdownListColumn : EditableColumn
- {
- public DictionaryItem DictionaryType { get; set; }
- public string FieldName { get; set; }
- protected override IDictionary<string, string> GetOptionsList()
- {
- var dictOptions = base.GetOptionsList();
- dictOptions.Add("columnType", "'dictionary'");
- //dictOptions.Add("dictionaryData",
- // string.Concat("[",
- // string.Join(",", DictionaryHelper.GetDictionaryValue(DictionaryType).Select(x => string.Format("{{ Text:'{0}',Value:'{1}' }}", x.Name, x.Value))),
- // "]"));
- dictOptions.Add("dictionaryCode", "'" + DictionaryType.ToString() + "'");
- if (!string.IsNullOrEmpty(FieldName))
- dictOptions.Add("fieldname", "\'" + FieldName + "\'");
- else
- throw new Exception("必须指定FieldName属性。");
- if (this.IsRequired.HasValue && this.IsRequired.Value)
- {
- if (this.Validator == null)
- {
- this.Validator = new DropdownListRequiredValidator();
- }
- dictOptions.Add("validateClass", "'" + this.Validator.ValidatorClass + "'");
- dictOptions.Add("validateOption", this.Validator.GetOptions().ToJson().Replace("\"", "'"));
- }
- return dictOptions;
- }
- }
- }
|