@using (Html.BeginForm("SaveCrossProjectPrice", "CspModule", FormMethod.Post, new {id = "validationForm"})) { <fieldset> <div id="layout" style="width: 100%; height: 485px; 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>Component</h4> </td> <td> @(Html.Infragistics().ComboFor(m=>m.ComponentSalesPrice.ComponentId) .ID("componentCombo") .Width("200px") .DataSource(Model.Components) .ValueKey("Id") .TextKey("ComponentId") .NullText("Select a Component") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.ComponentSalesPrice.ComponentId, new { @id = "ComponentId" }) </td></tr> <tr> <td> <h4>Effective 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> Effective 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> <h4>Event</h4> </td> <td> @(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.EventId) .ID("eventCombo") .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>Supplier</h4> </td> <td> @(Html.Infragistics().ComboFor(m => m.Supplier.SupplierName) .ID("SupplierCombo") .Width("200px") .DataSource(Model.Suppliers) .ValueKey("Id") .TextKey("SupplierName") .NullText("Select a Supplier") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.Supplier.SupplierName, new { @id = "Id" }) </td> </tr> <tr><td> <h4>Currency</h4> </td> <td> @(Html.Infragistics().ComboFor(m => m.Currency.CurrencyCode) .ID("CurrencyCombo") .Width("200px") .DataSource(Model.Currencies) .ValueKey("Id") .TextKey("CurrencyCode") .NullText("Select a Currency") .ValidatorOptions(options => options.Required(true)) .DataBind() .Render() ) @Html.HiddenFor(m => m.Currency.CurrencyCode, new { @id = "Id" }) </td></tr> <tr><td> <h4>New BasePrice</h4> </td> <td> @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.BasePriceExcludingIndexedMaterial) .ID("NewBasePrice") .Width(205) .MaxLength(4) .NullText("Enter a new base price") .ValidatorOptions(options => options.OnBlur(false).OnChange(false).OnSubmit(true)) .Required(true) .Render() ) </td></tr> <tr> <td> <h4>New Calculated SellingPrice</h4> </td> <td> @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.SellingPrice).ReadOnly(true) .ID("SellingPrice") .Width(205) .MaxLength(4) .Render() ) </td></tr> <tr> <td> <h4>New Selling Price Override</h4> </td> <td> @(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.SellingPriceOverride) .ID("SellingPriceOverride") .Width(205) .MaxLength(4) .Render() ) </td></tr> <tr><td> </td> <td> <input type="button" id="AmendPrice" class="button-style" value="Amend Price" /> </td> </tr><tr> </tr> </table> </div> </div> </fieldset> } } <script> $( function() { $('#customerCombo').change(function() { var selectedcustomer = $(this).val(); var componentCombo = $('#componentCombo'); $.ajax({ cache: false, type: "POST", url: "@Url.Action("GetComponentsbyCustomerId", "CspModule")", contentType: 'application/json; charset=utf-8', dataType: 'json', data: { "customerId": selectedcustomer }, success: function (data) { componentCombo.html(''); $.each(data, function(id, option) { componentCombo.append($('<option></option>'.val(option.componentId).html(option.componentId))); }); }, error: function(xhr, ajaxoptions, thrownError) { alert('failed to retrieve components'); } }); }); }); </script>
@using (Html.BeginForm("SaveCrossProjectPrice", "CspModule", FormMethod.Post, new {id = "validationForm"}))
{
<fieldset>
<div id="layout" style="width: 100%; height: 485px; 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>Component</h4>
@(Html.Infragistics().ComboFor(m=>m.ComponentSalesPrice.ComponentId)
.ID("componentCombo")
.DataSource(Model.Components)
.TextKey("ComponentId")
.NullText("Select a Component")
@Html.HiddenFor(m => m.ComponentSalesPrice.ComponentId, new { @id = "ComponentId" })
</td></tr>
<h4>Effective 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> Effective End Date</h4></td>
@(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.EffectiveEndDate)
.ID("EffectiveEndDate")
.NullText("Enter an Effective End Date")
<tr><td>
<h4>Event</h4>
@(Html.Infragistics().ComboFor(m => m.ComponentSalesPrice.EventId)
.ID("eventCombo")
.DataSource(Model.Events)
.TextKey("EventDescription")
.NullText("Select an event")
@Html.HiddenFor(m => m.ComponentSalesPrice.EventId, new { @id = "Id" })
<h4>Supplier</h4>
@(Html.Infragistics().ComboFor(m => m.Supplier.SupplierName)
.ID("SupplierCombo")
.DataSource(Model.Suppliers)
.TextKey("SupplierName")
.NullText("Select a Supplier")
@Html.HiddenFor(m => m.Supplier.SupplierName, new { @id = "Id" })
<h4>Currency</h4>
@(Html.Infragistics().ComboFor(m => m.Currency.CurrencyCode)
.ID("CurrencyCombo")
.DataSource(Model.Currencies)
.TextKey("CurrencyCode")
.NullText("Select a Currency")
@Html.HiddenFor(m => m.Currency.CurrencyCode, new { @id = "Id" })
<h4>New BasePrice</h4>
@(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.BasePriceExcludingIndexedMaterial)
.ID("NewBasePrice")
.NullText("Enter a new base price")
<h4>New Calculated SellingPrice</h4>
@(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.SellingPrice).ReadOnly(true)
.ID("SellingPrice")
<h4>New Selling Price Override</h4>
@(Html.Infragistics().TextEditorFor(m => m.ComponentSalesPrice.SellingPriceOverride)
.ID("SellingPriceOverride")
<tr><td> </td>
<input type="button" id="AmendPrice" class="button-style" value="Amend Price" />
</tr><tr> </tr>
</table>
</div>
</fieldset>
}
<script>
$( function() {
$('#customerCombo').change(function() {
var selectedcustomer = $(this).val();
var componentCombo = $('#componentCombo');
$.ajax({
cache: false,
type: "POST",
url: "@Url.Action("GetComponentsbyCustomerId", "CspModule")",
contentType: 'application/json; charset=utf-8',
dataType: 'json',
data: {
"customerId": selectedcustomer
},
success: function (data) {
componentCombo.html('');
$.each(data, function(id, option) {
componentCombo.append($('<option></option>'.val(option.componentId).html(option.componentId)));
});
error: function(xhr, ajaxoptions, thrownError) {
alert('failed to retrieve components');
</script>
Hello Venkatesh,
Thank you for contacting Infragistics!
We received your support request concerning retrieving the value from a combo box, and this case has been assigned to me. Infragistics is dedicated to helping you solve this issue. Our team and I have done an initial re case and I will try to create a sample to give a good example of this behavior. I will get back to you by the end of the day tomorrow with more information or questions for you.
You can retrieve the value from a combo box by calling a function on certain events and having this function retrieve the value in the combo box. For example, you can add .AddClientEvent('selectionChanged', 'func') to your combo box. This will call a function every time the value in the combo box changes. Please see the function which is called based on this event in the code snippet below:
In this example, you can see how we are able to retrieve the value of the igCombo. In this case the value is used to set the text value of a div in my sample. Please let me know if this clears things up for you.
Is there anything else I can assist you with on the matter? Please do not hesitate to contact me with more questions.