Hi all,
I hope I can explain this. I will try to put together a small sample, but I wanted to get this out there as soon as I could.
I'm using ASP.Net Core 2.0.
I have a grid that has a foreign key to an enum value on my model. I have an EditorTemplate set up, which builds a SelectList from the enum values and binds it to a Kendo DropDownList, and it works great:
@model MyEnumType
@{
var enumTypeSelect = Enum.GetValues(typeof(MyEnumType))
.Cast<
MyEnumType
>()
.Select(value => new SelectListItem()
{
Text = value.ToString(),
Value = ((int)value).ToString()
});
}
@(Html.Kendo().DropDownListFor(model => model)
.DataTextField("Text")
.DataValueField("Value")
.BindTo(enumTypeSelect))
And in my grid:
@(Html.Kendo().Grid<
MyViewModel
>(Model.Items)
.Name("grid")
.Columns(columns =>
{
columns.Bound(li => li.ID).Visible(false);
columns.Bound(li => li.EnumType).Width(170)
.ClientTemplate("#: Description #")
.EditorTemplateName("_GetValidEnumItemTypesPartial");
... rest of grid...
Now, though, I have a requirement where once I select certain enum types, I have to exclude OTHER enum types from subsequent entries in my model. This is similar to, but not exactly, like a set of cascading drop downs, where the contents of the second depend upon the first.
So, I need to filter those enum types from the list. I've tried a couple things:
- setting the drop down's dataSource filter, like this:
$("#LineItemType").data().kendoDropDownList.dataSource.filter({ field: 'Value', operator: 'neq', value: 1 })
or
$("#LineItemType").data().kendoDropDownList.dataSource.filter({ field: 'Text', operator: 'neq', value: 'MyValue' })
I've tried this at various places: when I've added the item to the grid, and when I'm about to add the item. This doesn't seem to work at all.
- Loading the list of valid values via Ajax - the problem there is that I don't know whether I'm updating the FIRST value (so I can set it to anything) or a NEW value (where I would restrict), so I can't reliably determine what the values should be.
Nothing seems to work so far.
There's an option that changes my data model - but I would rather not do this if I can avoid it.
Any help is appreciated - thanks!
Phil