/// <summary> /// Устанавливает настройки по-умолчанию для редактора комбабокса. /// </summary> /// <param name="settings">Настройки.</param> /// <param name="token">Токен безорпасности.</param> public static void SetDefaultSettings(this ComboBoxSettings settings, SecurityToken token) { settings.Width = Unit.Percentage(100); settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithTooltip; settings.ShowModelErrors = true; settings.Properties.ClearButton.DisplayMode = ClearButtonDisplayMode.OnHover; }
public static void LoadComboBoxSettings(ComboBoxSettings settings, string propertyName, bool isNullableValueType, string dictionaryUrl) { settings.Name = propertyName + "ComboBox"; settings.Width = new Unit("99%"); settings.Properties.DropDownStyle = DropDownStyle.DropDownList; settings.Properties.DropDownRows = 20; settings.Properties.EnableCallbackMode = true; settings.Properties.CallbackPageSize = 30; settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith; settings.Properties.TextFormatString = "{0}"; settings.Properties.ValueField = "Id"; settings.Properties.TextField = "Name"; settings.Properties.NullDisplayText = ""; settings.Properties.ValueType = typeof (Guid); settings.Properties.ClientSideEvents.ValueChanged = string.Format("function(){{ $('#{0}').val({1}.GetValue()); }}", propertyName, settings.Name); var buttonOnClick = new StringBuilder(); if (isNullableValueType) { settings.Properties.Buttons.Add(Resources.Resource.Clean); buttonOnClick.AppendLine(string.Format( @"case {0}: s.SetText(""""); s.SetValue(""""); $('#{1}').val(""""); break;", settings.Properties.Buttons.Count - 1, propertyName)); } if (!string.IsNullOrEmpty(dictionaryUrl)) { settings.Properties.Buttons.Add(Resources.Resource.Link); string toUrl = dictionaryUrl; if(dictionaryUrl[dictionaryUrl.Length - 1] != '/') toUrl += "/"; buttonOnClick.AppendLine(string.Format( @"case {0}: var objId = {1}.GetValue(); if(objId != undefined && objId != '') window.open('{2}' + objId); break;", settings.Properties.Buttons.Count - 1, settings.Name, toUrl)); } if (buttonOnClick.Length > 0) { settings.Properties.ClientSideEvents.ButtonClick = string.Format( @"function (s, e) {{ switch (e.buttonIndex) {{ {0} }} }}", buttonOnClick); } }
public ComboBoxSettings GenerateComboBoxDefaultSettings(ComboBoxSettings settings) { settings.Width = Unit.Percentage(100); settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains; settings.Properties.DropDownStyle = DropDownStyle.DropDown; return(settings); }
public void Configure(ComboBoxSettings settings, HtmlHelper html, ViewContext viewContext) { viewContext.Writer.Write("</br>"); settings.Name = "CheckListCombo"; settings.Width = Unit.Percentage(30); settings.Properties.TextField = "Name"; settings.Properties.ValueField = "Id"; settings.Properties.Caption = "Select Checklist / Protocol:"; settings.Properties.ClientSideEvents.SelectedIndexChanged = "CheckListComboOnSelectedIndexChanged"; }
public virtual void ConfigureFindingSubType(ComboBoxSettings settings, HtmlHelper htmlHelper, ViewContext viewContext) { var findingSubTypes = ViewData["findingSubTypes"] as IEnumerable <FindingSubType>; settings.Name = "FindingSubTypeId"; settings.CallbackRouteValues = new { Controller = BaseController, Action = "FindingSubTypePartial" }; settings.Properties.ValueField = "Id"; settings.Properties.TextField = "Name"; settings.Properties.ValueType = typeof(int); settings.Properties.ClientSideEvents.BeginCallback = "function(s, e) { e.customArgs['FindingTypeId'] = FindingTypeId.GetValue(); }"; }
public virtual void ConfigureFindingType(ComboBoxSettings settings, HtmlHelper htmlHelper, ViewContext viewContext) { if (ViewData["findingTypes"] == null) { ViewData["findingTypes"] = GetClient <FindingTypeClient>().GetAllAsync().Result.Result.Data; } var findingTypes = ViewData["findingTypes"] as IEnumerable <FindingType>; settings.Name = "FindingTypeId"; //settings.CallbackRouteValues = new { Controller = BaseController, Action = "FindingTypePartial" }; settings.Properties.DataSource = findingTypes; settings.Properties.ValueField = "Id"; settings.Properties.TextField = "Name"; settings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e) { debugger; FindingSubTypeId.PerformCallback(); }"; }
public static void LoadComboBoxSettings(ComboBoxSettings settings, string propertyName, bool isNullableValueType, string dictionaryUrl) { settings.Name = propertyName + "ComboBox"; settings.Width = new Unit("99%"); settings.Properties.DropDownStyle = DropDownStyle.DropDownList; settings.Properties.DropDownRows = 20; settings.Properties.EnableCallbackMode = true; settings.Properties.CallbackPageSize = 30; settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.StartsWith; settings.Properties.TextFormatString = "{0}"; settings.Properties.ValueField = "Id"; settings.Properties.TextField = "Name"; settings.Properties.NullDisplayText = ""; settings.Properties.ValueType = typeof(Guid); settings.Properties.ClientSideEvents.ValueChanged = string.Format("function(){{ $('#{0}').val({1}.GetValue()); }}", propertyName, settings.Name); var buttonOnClick = new StringBuilder(); if (isNullableValueType) { settings.Properties.Buttons.Add(Resources.Resource.Clean); buttonOnClick.AppendLine(string.Format( @"case {0}: s.SetText(""""); s.SetValue(""""); $('#{1}').val(""""); break;", settings.Properties.Buttons.Count - 1, propertyName)); } if (!string.IsNullOrEmpty(dictionaryUrl)) { settings.Properties.Buttons.Add(Resources.Resource.Link); string toUrl = dictionaryUrl; if (dictionaryUrl[dictionaryUrl.Length - 1] != '/') { toUrl += "/"; } buttonOnClick.AppendLine(string.Format( @"case {0}: var objId = {1}.GetValue(); if(objId != undefined && objId != '') window.open('{2}' + objId); break;", settings.Properties.Buttons.Count - 1, settings.Name, toUrl)); } if (buttonOnClick.Length > 0) { settings.Properties.ClientSideEvents.ButtonClick = string.Format( @"function (s, e) {{ switch (e.buttonIndex) {{ {0} }} }}", buttonOnClick); } }
public static void LoadComboBoxSettings(ComboBoxSettings settings, ViewDataDictionary viewData, string dictionaryUrl) { LoadComboBoxSettings(settings, viewData.ModelMetadata.PropertyName, viewData.ModelMetadata.IsNullableValueType, dictionaryUrl); }
public ComboBox(ComboBoxSettings settings, ViewContext context, IViewDataContainer viewDataContainer) : base(settings, context, viewDataContainer) { }
public ComboBox(ComboBoxSettings settings) : base(settings) { }
public static MvcHtmlString IvsDropDownDataList(this HtmlHelper helper, ControlSetting controlSetting) { settings = new ComboBoxSettings(); settings.ControlStyle.HorizontalAlign = controlSetting.HAlignment; settings.ControlStyle.VerticalAlign = controlSetting.VAlignment; settings.Enabled = controlSetting.Enabled; settings.Name = controlSetting.Name; settings.ReadOnly = controlSetting.ReadOnly; settings.TabIndex = controlSetting.TabIndex; settings.ToolTip = controlSetting.ToolTip; settings.Width = controlSetting.Width; if (controlSetting.MaxLength > 0) { settings.Properties.MaxLength = controlSetting.MaxLength; } switch (controlSetting.DropDownStyle) { case Ivs.Controls.CustomControls.Infrastructure.DropDownStyle.DropDown: settings.Properties.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDown; break; case Ivs.Controls.CustomControls.Infrastructure.DropDownStyle.DropDownList: settings.Properties.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDownList; break; default: settings.Properties.DropDownStyle = DevExpress.Web.ASPxEditors.DropDownStyle.DropDown; break; } settings.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains; settings.Properties.Columns.Add(controlSetting.ValueMember); settings.Properties.Columns.Add(controlSetting.DisplayMember); //settings.Properties.Columns[0].Caption = CommonData.StringEmpty; //settings.Properties.Columns[1].Caption = CommonData.StringEmpty; //settings.Properties.DataSource = controlSetting.DataSource; settings.Properties.ValueField = controlSetting.ValueMember; //settings.Properties.DataMember = controlSetting.DisplayMember; settings.Properties.TextField = controlSetting.DisplayMember; settings.Properties.ValueType = controlSetting.ValueMember.GetType(); settings.Properties.EnableClientSideAPI = true; //generate regular input without table //settings.Properties.Native = true; #region Set selected value if any // if the valueToBindTo was found, bind it as the selected value //if (bindObject != null) // comboBox.Bind(bindObject); //if (!CommonMethod.IsNullOrEmpty(controlSetting.SelectedValue)) //{ // settings.PreRender = (sender, e) => // { // MVCxComboBox cbo = sender as MVCxComboBox; // cbo.Value = controlSetting.SelectedValue; // }; //} //if (controlSetting.SelectedIndex >= 0) //{ // settings.PreRender = (sender, e) => // { // MVCxComboBox cbo = sender as MVCxComboBox; // cbo.SelectedIndex = controlSetting.SelectedIndex; // }; //} #endregion if (CommonMethod.IsNullOrEmpty(controlSetting.Value)) { new ComboBoxExtension(settings, helper.ViewContext).BindList(controlSetting.DataSource).Render(); } else { new ComboBoxExtension(settings, helper.ViewContext).BindList(controlSetting.DataSource).Bind(controlSetting.Value).Render(); } return(MvcHtmlString.Empty); }
/// <summary> /// 为 <see cref="HtmlHelper"/> 对象扩展 validatebox 元素。使用一个枚举类型输出 Key-Value 数组,Value 是使用 <see cref="EnumDescriptionAttribute"/> 标注的。 /// </summary> /// <typeparam name="TModel">数据模型类型。</typeparam> /// <typeparam name="TProperty">绑定的属性的类型。</typeparam> /// <param name="htmlHelper"></param> /// <param name="expression">指定绑定属性的表达式。</param> /// <param name="enumType">要绑定的枚举类型。</param> /// <param name="settings">参数选项。</param> /// <returns></returns> public static HtmlHelper <TModel> ComboBox <TModel, TProperty>(this System.Web.Mvc.HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, Type enumType, ComboBoxSettings settings = null) { return(new HtmlHelper <TModel>().ComboBox(expression, enumType, settings)); }
/// <summary> /// 为 <see cref="HtmlHelper"/> 对象扩展 combobox 元素。 /// </summary> /// <param name="htmlHelper"></param> /// <param name="exp">属性名或使用 cbo 作为前缀的 ID 名称。</param> /// <param name="enumType">枚举类型。</param> /// <param name="settings">参数选项。</param> /// <returns></returns> public static HtmlHelper ComboBox(this System.Web.Mvc.HtmlHelper htmlHelper, string exp, Type enumType, ComboBoxSettings settings = null) { return(new HtmlHelper().ComboBox(exp, enumType, settings)); }