27 lines
980 B
C#
27 lines
980 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq.Expressions;
|
|
using System.Web.Mvc;
|
|
using Kendo.Mvc.UI;
|
|
using Kendo.Mvc.UI.Fluent;
|
|
|
|
namespace Kreta.Web.Helpers.Unhacked
|
|
{
|
|
public static class RadioButtonExtensions
|
|
{
|
|
public static List<RadioButtonBuilder> KendoRadioButtonsFor<TModel, TProperty, T>(this HtmlHelper<TModel> html,
|
|
Expression<Func<TModel, TProperty>> expression, List<T> options, Expression<Func<T, object>> idExpression, Expression<Func<T, string>> labelExpression)
|
|
{
|
|
var idMethod = idExpression.Compile();
|
|
var labelMethod = labelExpression.Compile();
|
|
var radioButtonBuilders = new List<RadioButtonBuilder>();
|
|
|
|
foreach (var option in options)
|
|
{
|
|
radioButtonBuilders.Add(html.Kendo().RadioButtonFor(expression).Label(labelMethod(option)).Value(idMethod(option)));
|
|
}
|
|
|
|
return radioButtonBuilders;
|
|
}
|
|
}
|
|
}
|