J'ai besoin de charger une liste déroulante dépendante de jqgrid. Voici une partie de mon code (j'utilise MVC)Liste déroulante dépendante jqgrid
{ name: 'parIDUnidadMedida', index: 'parIDUnidadMedida', width: 80, align: 'center', editable: true, edittype: "select",
editrules: { required: true },
editoptions: {
multiple: false,
size: 1,
dataUrl: '@Url.Content("~/")' + 'CertificadoGarantiaExtendidaOpciones/ListarUnidadesMedida/',
buildSelect: function (data) {
var response = jQuery.parseJSON(data);
var s = '<select>';
if (response && response.length) {
for (var i = 0, l = response.length; i < l; i++) {
var ri = response[i];
s += '<option value="' + ri.Value + '">' + ri.Text + '</option>';
}
}
return s + "</select>";
},
dataEvents: [{
type: 'change',
fn: function (e) {
var varIDUnidadMedida = e.currentTarget.value;
newOptions = '';
var arrPlazos = $.ajax({
url: '@Url.Content("~/")' + 'CertificadoGarantiaExtendidaOpciones/ListarPlazos/' + varIDUnidadMedida,
async: false
}).responseText;
var response = jQuery.parseJSON(arrPlazos);
for (var i = 0; i < response.length; i++) {
newOptions += '<option value="' + response[i].Value + '">' + response[i].Text + '</option>';
}
$('parPlazo').html(newOptions);
}
}]
}
},
{ name: 'parPlazo', index: 'parPlazo', width: 80, align: 'center', editable: true, edittype: "select",
editrules: { required: true },
editoptions: {
multiple: false,
size: 1
}
},
Comme vous pouvez le voir si le changement de contrôle de sélection parIDUnidadMedida puis parPlazo doit être mis à jour ...
Pouvez-vous me aider ?? Je ne sais pas comment le résoudre.
Cordialement.
ce lik m'a aidé .... http://www.trirand.net/aspnetmvc/grid/editdialogdependentdropdowns –
J'ai trouvé quelque chose d'autre à faire ..... Remplacer (ajouter un nouveau ligne de code) jQuery ("select #" + rowId + "_parPlazo"). append (plazosHtml); avec jQuery ("select #" + rowId + "_parPlazo> option"). Remove (plazosHtml); jQuery ("select #" + rowId + "_parPlazo"). Append (plazosHtml); –