Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2715
igCombo cascading mvc update form
posted

I have 2 comboboxes which Works perfect in a create form with a empty model

when I use the same 2 comboboxes in an update form only the first is populated

@(Html.Infragistics()
.ComboFor(m => m.omvisning.Bestiller_ID)
.ID("ddBestiller")
.TextKey("Navn")
.ValueKey("ID")
.Width("350px")
.NullText("Vælg bestiler")
.FilteringType(ComboFilteringType.Local)
.AutoComplete(true)
.DataSourceUrl("/Omvisning/Find_Bestiller")
.FilterExprUrlKey("filter")
.ValidatorOptions(o => o.Required(true))
.DataBind()
.Render()
)

@(Html.Infragistics()
.ComboFor(m => m.omvisning.Kontakt_ID)
.ID("ddKontakt")
.TextKey("Person")
.ValueKey("ID")
.Width("350px")
.FilteringType(ComboFilteringType.Local)
.AutoComplete(true)
.DataSourceUrl("/Omvisning/Find_Kontakt")
.FilterExprUrlKey("filter")
.NullText("Vælg kontaktperson")
.CascadingSettings(settings => settings.ParentComboID("#ddBestiller").ParentComboKey("Firma_ID"))
.DataBind()
.Render()
)

I also have this JavaScript

$("#ddBestiller").igCombo({ selectionChanged: ddBestiller_Valgt });
$("#ddKontakt").igCombo({ selectionChanged: ddKontakt_Valgt });

function ddBestiller_Valgt(evt, ui) {

if (ui.items != null) {

var id = ui.items[0].value;

var postData = { "ID": id };

$.getJSON("@Url.Content("~/Omvisning/Hent_Bestiller")", postData, function (data) {

if (data.OK == "JA")

{

$("#txtAdresse").text(data.Adresse);

$("#txtPostnr").text(data.Postnr);

$("#txtBynavn").text(data.Bynavn);

$("#txtLand").text(data.Land);

$("#txtEAN").text(data.EAN == null ? "" : data.EAN);

$("#txtSEnr").text(data.SENR == null ? "" : data.SENR);

$("#cbInstitution").prop("checked", data.Institution);

$("#cbSend_Email").prop("checked", data.Send_Email);

$("#cbForening").prop("checked", data.Forening);

$("#ddKontakt").igCombo("getData");

$("#ddKontakt").igCombo("selectedIndex", 0);

$("#ddKontakt").igCombo("activeIndex", 0);

var item = $("#ddKontakt").igCombo("itemByIndex", 0);

if (item.value != null) {

hent_kontakt(item.value);

}

}

});

return false;

}

};

function ddKontakt_Valgt(evt, ui) {

if (ui.items != null) {

var id = ui.items[0].value;

hent_kontakt(id);

return false;

}

};

function hent_kontakt(id)

{

var postData = { "ID": id };

$.getJSON("@Url.Content("~/Omvisning/Hent_Kontakt")", postData, function (data) {

if (data.OK == "JA")

{

$("#txtRefnr").text(data.refnr);

$("#txtEmail").text(data.Email);

$("#txtTlf_K").text(data.Tlf);

}

});

}