init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
60
KretaWeb/Helpers/Unhacked/ComboBoxExtensions.cs
Normal file
60
KretaWeb/Helpers/Unhacked/ComboBoxExtensions.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Web.Mvc;
|
||||
using Kendo.Mvc.UI;
|
||||
using Kendo.Mvc.UI.Fluent;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.Web.Helpers.Unhacked
|
||||
{
|
||||
public static class ComboBoxExtensions
|
||||
{
|
||||
public struct ComboBoxParameters
|
||||
{
|
||||
public string Name;
|
||||
public string Action;
|
||||
public string Controller;
|
||||
public string Area;
|
||||
public string Placeholder;
|
||||
public string Language;
|
||||
public FilterType FilterType;
|
||||
public string ContentType;
|
||||
public bool ServerFiltering;
|
||||
|
||||
public ComboBoxParameters(string name, string action, string controller = "Enum", string area = "", string placeholder = null, string language = "Magyar",
|
||||
FilterType filterType = FilterType.Contains, string contentType = Kreta.Core.Constants.ContentTypes.ApplicationJson, bool serverFiltering = false)
|
||||
{
|
||||
Name = name;
|
||||
Action = action;
|
||||
Controller = controller;
|
||||
Area = area;
|
||||
Language = language;
|
||||
FilterType = filterType;
|
||||
ContentType = contentType;
|
||||
ServerFiltering = serverFiltering;
|
||||
Placeholder = placeholder ?? CommonResource.PleaseChoose;
|
||||
}
|
||||
}
|
||||
public static ComboBoxBuilder KendoComboBoxFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, ComboBoxParameters parameters)
|
||||
{
|
||||
return html.Kendo().ComboBoxFor(expression)
|
||||
.Name(parameters.Name + "ComboBox")
|
||||
.Placeholder(parameters.Placeholder)
|
||||
.DataTextField(parameters.Language)
|
||||
.DataValueField("Id")
|
||||
.Filter(parameters.FilterType)
|
||||
.DataSource(source =>
|
||||
{
|
||||
source.Custom()
|
||||
.ServerFiltering(parameters.ServerFiltering)
|
||||
.Transport(transport =>
|
||||
{
|
||||
transport.Read(read =>
|
||||
{
|
||||
read.ContentType(parameters.ContentType).Action(parameters.Action, parameters.Controller, new { parameters.Area });
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue