This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,27 @@
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;
}
}
}