I am using 2 combo boxes for drop downs. The combo boxes are cascading combo boxes, where one combo box value should be populated based on the selected value in the combo box. Here is my view, controller and model code. Please any one can help me. Many thanks in advance //View . @using Infragistics.Web.Mvc @model SEWSE.Commercial.UI.Web.Models.IndexedMaterialPriceChangeViewModel @{ ViewBag.Title = "IndexedMaterialPriceChange"; } <h2>IndexedMaterialPriceChange</h2> @section Head { <style type="text/css"> input.button-style { margin-top: 10px; } .ui-iggrid th, .ui-iggrid th.ui-state-default, .ui-iggrid th.ui-state-hover, .ui-iggrid th.ui-state-active { text-align: left; white-space: pre-wrap; } div#layout { background-color: #777; padding: 15px; border-radius: 5px; /*border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;*/ } div#layout .left p, div#layout .right p, div#layout .center p, div#layout h3 { margin: 15px; } div#layout .center { background-color: #EEE; color: #555; } div#layout .right { background-color: #555; color: #EEE; border-radius: 5px; } div#layout .left { padding-left: 20px; background-color: #EEE; border-radius: 5px; } div#layout .header { background-color: #2CBDF9; } div#layout .footer { background-color: #2CBDF9; } .hidden { display: none !important; } </style> <script> $(document).ready(function () { $("#projectCombo").prop("disabled", true); $("#customerCombo").change(function () { if ($("#customerCombo").val() != "Please select") { var options = {}; options.url = "/IndexedMaterialPriceChange/getproject"; options.type = "POST"; options.data = JSON.stringify({ country: $("#customerCombo").val() }); options.dataType = "json"; options.contentType = "application/json"; options.success = function (states) { $("#projectCombo").empty(); for (var i = 0; i < states.length; i++) { $("#projectCombo").append("<option>" + states[i] + "</option>"); } $("#projectCombo").prop("disabled", false); }; options.error = function () { alert("Error retrieving !"); }; $.ajax(options); } else { $("#projectCombo").empty(); $("#projectCombo").prop("disabled", true); } }); }); </script> } @section Body { <h2>@ViewBag.Title</h2> @using (Ajax.BeginForm("Index","./IndexedMaterialPriceChange/IndexedMaterialPriceChange", new AjaxOptions { UpdateTargetId = "result" })) { <fieldset> <div id="layout" style="width: 100%; height: 400px; display: block"> <div id="crossprojectpriceGridDiv" class="left" style="width: 100%"> <table> <tr> <td><h4> Customer</h4></td> <td> @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.CustomerId) .ID("customerCombo") .Width("200px") .DataSource(Model.Customers) .ValueKey("Id") .TextKey("CustomerName") .NullText("Select a Customer") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.ComponentSalesPrice.CustomerId, new { @id = "CustomerId" }) </td> </tr> <tr> <td> <h4>Project</h4> </td> <td> @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.ProjectId) .ID("projectCombo") .Width("200px") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.ComponentSalesPrice.ProjectId, new { @id = "ProjectId" }) </td> </tr> <tr> <td> <h4>Previous Event</h4> </td> <td> @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.EventId) .ID("preveventCombo") .Width("200px") .DataSource(Model.EventId) .ValueKey("Id") .TextKey("EventId") .NullText("Select an event") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.ComponentSalesPrice.EventId, new { @id = "Id" }) </td> </tr> <tr> <td> <h4>New Event</h4> </td> <td> @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.EventId) .ID("neweventCombo") .Width("200px") .DataSource(Model.Events) .ValueKey("Id") .TextKey("EventDescription") .NullText("Select an event") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.ComponentSalesPrice.EventId, new { @id = "Id" }) </td> </tr> <tr> <td> <h4>New Start Date </h4> </td> <td> @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveStartDate) .ID("EffectiveStartDate") .Width(205) .MaxLength(4) .NullText("Enter an Effective Start Date") .ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true)) .Required(true) .Render() ) </td> </tr> <tr> <td><h4> New End Date</h4></td> <td> @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveEndDate) .ID("EffectiveEndDate") .Width(205) .MaxLength(4) .NullText("Enter an Effective End Date") .ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true)) .Required(true) .Render() ) </td> </tr> <tr> <td> <input type="button" id="AmendPrice" class="button-style" value="Amend Price" /> </td> </tr> </table> </div> </div> </fieldset> } } // Controller: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web.Mvc; using SEWSE.Commercial.Entities.CSP; using SEWSE.Commercial.Entities.Masters; using SEWSE.Commercial.UI.Process; using SEWSE.Commercial.UI.Web.Models; namespace SEWSE.Commercial.UI.Web.Controllers.CspModule { public partial class CspModuleController { public ActionResult IndexedMaterialPriceChange() { ViewBag.DllVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); var ppc = new ProjectProcessComponent(); var custpc = new CustomerProcessComponent(); var epc = new EventProcessComponent(); var csp = new ComponentSalesPriceProcessComponent(); var viewModel = new IndexedMaterialPriceChangeViewModel { Customers = custpc.Select(), Projects = ppc.Select(), Events = epc.Select(), }; return View(viewModel); } public JsonResult GetProject(int customer) { List<string> projectsList = new List<string>(); var project = new ComponentSalesPriceProcessComponent(); var projects = project.SelectByCustomerId(customer); foreach (ComponentSalesPrice proj in projects) { projectsList.Add(proj.ProjectId.ToString()); } return Json(projectsList); } public void SaveIndexedMaterialPriceChange() { } } } //Model: namespace SEWSE.Commercial.UI.Web.Models { public class IndexedMaterialPriceChangeViewModel { public IEnumerable<Customer> Customers { get; set; } public IEnumerable<Project> Projects { get; set; } public IEnumerable<Event> Events { get; set; } public IEnumerable<ComponentSalesPrice> ComponentSalesPrices { get; set; } public ComponentSalesPrice ComponentSalesPrice { get; set; } public List<ComponentSalesPrice> EventId { set; get; } } }
I am using 2 combo boxes for drop downs. The combo boxes are cascading combo boxes, where one combo box value should be populated based on the selected value in the combo box. Here is my view, controller and model code. Please any one can help me. Many thanks in advance
//View .
@using Infragistics.Web.Mvc
@model SEWSE.Commercial.UI.Web.Models.IndexedMaterialPriceChangeViewModel
@{
ViewBag.Title = "IndexedMaterialPriceChange";
}
<h2>IndexedMaterialPriceChange</h2>
@section Head
{
<style type="text/css">
input.button-style {
margin-top: 10px;
.ui-iggrid th, .ui-iggrid th.ui-state-default, .ui-iggrid th.ui-state-hover, .ui-iggrid th.ui-state-active {
text-align: left;
white-space: pre-wrap;
div#layout {
background-color: #777;
padding: 15px;
border-radius: 5px;
/*border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;*/
div#layout .left p, div#layout .right p, div#layout .center p, div#layout h3 {
margin: 15px;
div#layout .center {
background-color: #EEE;
color: #555;
div#layout .right {
background-color: #555;
color: #EEE;
div#layout .left {
padding-left: 20px;
div#layout .header {
background-color: #2CBDF9;
div#layout .footer {
.hidden {
display: none !important;
</style>
<script>
$(document).ready(function () {
$("#projectCombo").prop("disabled", true);
$("#customerCombo").change(function () {
if ($("#customerCombo").val() != "Please select") {
var options = {};
options.url = "/IndexedMaterialPriceChange/getproject";
options.type = "POST";
options.data = JSON.stringify({ country: $("#customerCombo").val() });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (states) {
$("#projectCombo").empty();
for (var i = 0; i < states.length; i++) {
$("#projectCombo").append("<option>" + states[i] + "</option>");
$("#projectCombo").prop("disabled", false);
};
options.error = function () { alert("Error retrieving !"); };
$.ajax(options);
else {
});
</script>
@section Body {
<h2>@ViewBag.Title</h2>
@using (Ajax.BeginForm("Index","./IndexedMaterialPriceChange/IndexedMaterialPriceChange", new AjaxOptions { UpdateTargetId = "result" }))
<fieldset>
<div id="layout" style="width: 100%; height: 400px; display: block">
<div id="crossprojectpriceGridDiv" class="left" style="width: 100%">
<table>
<tr>
<td><h4> Customer</h4></td>
<td>
@(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.CustomerId)
.ID("customerCombo")
.Width("200px")
.DataSource(Model.Customers)
.ValueKey("Id")
.TextKey("CustomerName")
.NullText("Select a Customer")
.ValidatorOptions(options => options.Required(true))
.DataBind()
.Render()
)
@Html.HiddenFor(m => m.ComponentSalesPrice.CustomerId, new { @id = "CustomerId" })
</td>
</tr>
<h4>Project</h4>
@(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.ProjectId)
.ID("projectCombo")
@Html.HiddenFor(m => m.ComponentSalesPrice.ProjectId, new { @id = "ProjectId" })
<h4>Previous Event</h4>
@(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.EventId)
.ID("preveventCombo")
.DataSource(Model.EventId)
.TextKey("EventId")
.NullText("Select an event")
@Html.HiddenFor(m => m.ComponentSalesPrice.EventId, new { @id = "Id" })
<h4>New Event</h4>
.ID("neweventCombo")
.DataSource(Model.Events)
.TextKey("EventDescription")
<h4>New Start Date </h4>
@(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveStartDate)
.ID("EffectiveStartDate")
.Width(205)
.MaxLength(4)
.NullText("Enter an Effective Start Date")
.ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true))
.Required(true)
<td><h4> New End Date</h4></td>
@(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveEndDate)
.ID("EffectiveEndDate")
.NullText("Enter an Effective End Date")
<input type="button" id="AmendPrice" class="button-style" value="Amend Price" />
</table>
</div>
</fieldset>
// Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web.Mvc;
using SEWSE.Commercial.Entities.CSP;
using SEWSE.Commercial.Entities.Masters;
using SEWSE.Commercial.UI.Process;
using SEWSE.Commercial.UI.Web.Models;
namespace SEWSE.Commercial.UI.Web.Controllers.CspModule
public partial class CspModuleController
public ActionResult IndexedMaterialPriceChange()
ViewBag.DllVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
var ppc = new ProjectProcessComponent();
var custpc = new CustomerProcessComponent();
var epc = new EventProcessComponent();
var csp = new ComponentSalesPriceProcessComponent();
var viewModel = new IndexedMaterialPriceChangeViewModel
Customers = custpc.Select(),
Projects = ppc.Select(),
Events = epc.Select(),
return View(viewModel);
public JsonResult GetProject(int customer)
List<string> projectsList = new List<string>();
var project = new ComponentSalesPriceProcessComponent();
var projects = project.SelectByCustomerId(customer);
foreach (ComponentSalesPrice proj in projects)
projectsList.Add(proj.ProjectId.ToString());
return Json(projectsList);
public void SaveIndexedMaterialPriceChange()
//Model:
namespace SEWSE.Commercial.UI.Web.Models
public class IndexedMaterialPriceChangeViewModel
public IEnumerable<Customer> Customers { get; set; }
public IEnumerable<Project> Projects { get; set; }
public IEnumerable<Event> Events { get; set; }
public IEnumerable<ComponentSalesPrice> ComponentSalesPrices { get; set; }
public ComponentSalesPrice ComponentSalesPrice { get; set; }
public List<ComponentSalesPrice> EventId { set; get; }
Hello Maya,
Thanks alot for your answer.
Hello venkatesh ,
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Thank you for posting in our forum.
The standard implementation cascading combo boxes does not require manually appending items to it.
Instead you simply need to set for the combo the parentCombo and parentComboKey which it should use to filter it’s results based on the parent combo selection.
The parentCombo option determined the id of the parent combo and the parentComboKey determines the column key in the dataSource, which will be used by the cascading functionality in order to get records matching with selected value in the parent igCombo.
You can read more about this approach here:
http://help.infragistics.com/doc/jQuery/2014.1/CLR4.0/?page=igCombo_Binding_Cascading_igCombo_Controls_to_Individual_Data_Sources.html
You can refer to the following online sample with this implemented:
http://www.igniteui.com/combo/cascading-combos
If you prefer the filtering based on the parent combo’s value to not be done on client but instead you would prefer to manually handle the filtering of the data on the server side you make a ajax call to the server and retrieve the json data you want to bind the combo to.
For example:
$.ajax({
url: url,
data: data,
success: success,
dataType: dataType
For more information on how to make an ajax get request you can refer to:
http://api.jquery.com/jquery.get/
On the success method you’ll get the json result that was returned from the server and you can set it as the data source of your second combo and call data bind.
To set the data source:
$(".selector").igCombo("option", "dataSource", jsonData);
To call databind:
$(".selector").igCombo("dataBind");
Where “.selector” is the jQuery selector for the igCombo.
Let me know if you have any questions.
Developer Support Engineer II