I'm writing an ASP.NET MVC5 application using Ignite. I have 3 cascading combo boxes that I need to populate via Ajax calls. I'll show the first 2 as the third follows the same pattern and has the same issue as the third. My issue is that after post, the cascaded combo's lose their values. (The "Parent" works fine)
LMK if you need more details
@Html.LabelFor(model => model.GroupId, "Group") <div> @(Html.Infragistics() .ComboFor(model => model.GroupId) .ID("cmbGroups") .Width("200px") .TextKey("GroupName") .ValueKey("GroupId") .DataSourceUrl(Url.Action("group-combo-data")) .EnableClearButton(false) .DataBind() .Render()) </div>
@Html.LabelFor(model => model.ProjectId, "Project") <div> @(Html.Infragistics() .ComboFor(model => model.ProjectId) .ID("cmbProjects") .Width("200px") .TextKey("ProjectName") .ValueKey("ProjectId") .DataBind() .Render()) </div>
JavaScript to populate
<script type="text/javascript"> $(document).delegate("#cmbGroups", "igcomboselectionchanged", function (evt, ui) { var cmbGroups = ui.owner; var groupId = cmbGroups.value(); var postData = { "groupId": groupId }; $.getJSON('@Url.Action("GetProjectsByGroupId", "Report")', postData, function (returnData) { $("#cmbProjects").igCombo({ ID: "cmbProjects", Name: "cmbProjects", dataSourceType: "json", dataSource: returnData, textKey: "ProjectName", valueKey: "ProjectId", enableClearButton: false }); }); });
Hello fuzzbone,
In the sample provided, client side filtering is used on the original dataSet and the resulting JSON is applied as the DataSource for the igCombo and then DataBind is called to populate the igCombo. You can take another approach such as obtaining the DataSource through an AJAX call and then calling DataBind if needed.
Can you explain in detail what approach you wish to take to obtain the data?
I absolutely reviewed your samples and didn't find it a good match to what I'm trying to achieve. If I understand your sample you have the entire data results for the 3 datasources and then use client side filtering. It is certainly more efficient in a case where you have 2 countries and a dozen towns.
For large datasets this is unacceptable and is MUCH less efficient as we have to query the entire tables. As I mentioned there is a third level of cascading I haven't displayed.
My database will be much larger - hence i only want to return the Projects for the selected Group - not the entire table.
You can look into our sample here on how to implement cascading dropdown: http://www.igniteui.com/combo/cascading-combos
Note how in the the sample this behavior is achieved by reassigning a dataSource of the targerted igCombo and then calling the dataBind method. This is also more efficient than reinitializing another igCombo.