Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:05:00+00:00 2026-05-25T00:05:00+00:00

I need to load a dropdownlist dependent using jqgrid. Here’s part of my code

  • 0

I need to load a dropdownlist dependent using jqgrid. Here’s part of my code (I’m using MVC)

{ 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
                    }
                },

As you can see if the parIDUnidadMedida select control change then parPlazo must be updated…

Can you help me?? I don’t know how to solve it.

Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:05:01+00:00Added an answer on May 25, 2026 at 12:05 am

    Ok… after looking for an answer I got it..
    You see I made some minor fixes, but the main reason because it didn’t work was because I’ve never loaded the second dropdownlist (parPlazo). So the select parPlazo didn’t have id or name. Obviously it coudl never be reached

    Here’s the code. I hope this helps you.
    Regards

    { 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;
                                    $.ajax({
                                        url: '@Url.Content("~/")' + 'CertificadoGarantiaExtendidaOpciones/ListarPlazos/' + varIDUnidadMedida,
                                        type: 'GET',
                                        success: function (PlazosJson) {
                                            var plazos = eval(PlazosJson);
                                            var plazosHtml = "";
                                            $(plazos).each(function (i, option) {
                                                plazosHtml += '<option value="' + option.Value + '">' + option.Text + '</option>';
                                            });
    
                                            // Poblar los datos
                                            if ($(e.target).is('.FormElement')) {
                                                // En caso de se formulario de edicion, añadir
                                                var form = $(e.target).closest('form.FormGrid');
                                                $("select#parPlazo.FormElement", form[0]).html(plazosHtml);
                                            } else {
                                                // Edicion de una linea
                                                var row = $(e.target).closest('tr.jqgrow');
                                                var rowId = row.attr('id');
                                                var rowId = jQuery("#grid").jqGrid('getGridParam', 'selrow');
                                                jQuery("select#" + rowId + "_parPlazo").append(plazosHtml);
                                            }
                                        }
                                    });
                                }
                            }]
                        }
                    },
                    { name: 'parPlazo', index: 'parPlazo', width: 80, align: 'center', editable: true, edittype: "select",
                        editrules: { required: true },
                        editoptions: {
                            multiple: false,
                            size: 1,
                            dataUrl: '@Url.Content("~/")' + 'CertificadoGarantiaExtendidaOpciones/ListarPlazos/1',
                            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>";
                            }
                        }
                    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to load an XML source using Simple XML, duplicate an existing node
Two Delphi programs need to load foo.dll, which contains some code that injects a
I need to load an xML file from the bin folder in ASP.NET (MVC,
Need load parameters to function, creating a variable name on the fly terrible thing,
I need to load about 60 images, each on a different page, in to
I need to load an image from a web in a simple Java stand
I need to load a model, existing of +/- 20 tables from the database
I need to load a .xml file from a URL adress into an NSData
I need to load a file from an umounted TrueCrypt disk into memory. Is
I need to load some resource from my DLL (i need to load them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.