Hello, I'm using a cascading combobox in an editor template. The Id is set dynamically to avoid conflict with multiple instances of the editor on the same page. So for example I might setup the editor like this:
@Html.EditorFor(o => o.MatterNum, "MatterComboBox", new { ControlId = "upload_Matter" })
It sets the Id dynamically and that works great ( see below ). The problem I'm having is with cascading, because the parent combobox is also dynamic, so I don't know what the ID will be in my additional data method. I need to be able to somehow pass the ID of the parent combobox when setting up the child. Here is how my child combo is defined (the parent is very similar):
@(Html.Kendo().ComboBoxFor(o => o)
.DataTextField("MatterNumName")
.DataValueField("MatterNum")
.Placeholder("Select Matter")
.HtmlAttributes(new { id = @ViewData["ControlId"], style = "width: 100%" })
.Filter("contains")
.AutoBind(true)
.MinLength(1)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetFilteredMatters", "ClientMatter")
.Data("onAdditionalMatterData");
})
.ServerFiltering(true);
})
)
I've come at this from a few angles but coming up short each time.
1. I can set the child/parent IDs to be similar so I could just infer the parent Id from the child. However I haven't found a way to get the child combobox Id inside the onAdditionalMatterData js function, it seems to only contain the filter data (which I also need). If there was a way to get the sending control information out of that fitler object I think it would solve my issue.
2. I thought maybe I could pass the Id along from the template view to the onAdditionalMatterData function, something like this:
.Data("eBillReady.ClientMatterLookups.onAdditionalMatterData('parentId')");
but I'm not sure how to do that without losing the filter data which is then no longer passed, also I would obviously need the name to populate dynamically perhaps from the viewdata.
3. I think if I dynamically set "CascadeFrom", then that may cause the Id to be part of that filters object passed to onAdditionalMatterData but I didn't get anywhere with that. Maybe setting that manually in the page load would work?