I have a Session object. Each Session can be related to many Templates and each template has a list of Items (like an Enum list). Users can define a Template and its List of enums. The fun is that the user needs to filter on these dynamic properties and I'm trying to figure out how to do it. I need your help.
Template 1
- List Item 1
- List Item 2
- List Item 3
In the field list I need the list of Templates... which is dynamic. Right now, I have "Name". I need "Template 1", "Template 2", etc. Then, I need a pick list for each of them based on their own Items. So, select template 1 and filter on List Item 1. Give me all the sessions where Template 1's value is List Item 1. How do I do this in your Filter control.
Also, a side note. There is NO documentation on how to define the Html.Kendo().DataSource object. I don't believe my example works. I actually have the values in the MODEL and would like to just use the given values without needing to perform an Action.
View:
@(Html.Kendo().DataSource<
SessionOptionTemplate
> ()
.Name("templateDataSource")
.Ajax(d => d.Read(
r => r.Action("Templates", "Sessions"))))
@(Html.Kendo().Filter<
SessionOptionTemplate
>()
.Name("filter")
.MainLogic(FilterCompositionLogicalOperator.Or)
.ApplyButton()
.ExpressionPreview()
.Fields(f =>
{
f.Add(p => p.Name).Label("Name");
})
.DataSource("templateDataSource"))
Controller:
public async Task<
IActionResult
> Templates(
[DataSourceRequest] DataSourceRequest request)
{
var dsResult = await profileService.SessionOptionTemplates.ToDataSourceResultAsync(request);
return Json(dsResult);
}
Template:
public partial class SessionOptionTemplate
{
public int Id { get; set; }
[MaxLength(50)]
public string Name { get; set; }
[MaxLength(128)]
public string Description { get; set; }
public int Order { get; set; }
public DateTime AddTimestamp { get; set; } = DateTime.UtcNow;
public DateTime? DeactivateTimestamp { get; set; }
public ICollection<
SessionOptionItem
> SessionOptionItems { get; set; } = new HashSet<
SessionOptionItem
>();
}
Items:
public partial class SessionOptionItem
{
[Key]
public int Id { get; set; }
public int SessionOptionTemplateId { get; set; }
[MaxLength(50)]
public string Name { get; set; }
[MaxLength(128)]
public string Description { get; set; }
public DateTime AddTimestamp { get; set; } = DateTime.UtcNow;
public DateTime? DeactivateTimestamp { get; set; }
}