Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Cascading Dropdowns

Cascading Dropdowns

Scheduled Pinned Locked Moved JavaScript
helpasp-netcsharpcsssysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eddieangel
    wrote on last edited by
    #1

    I am sure this has been asked a million times, but I am going to ask again because I can't find a good answer to my specific issue. I am using MVC asp.net and I want to load data through Ajax when a row in a Telerik grid goes into edit mode. I can get the data to load and everything is good, but I can't get the cascading drop down to work. Here is my change event code, the error is somewhere in here:

    $(document).ready(function () {
    
        $('#categoryId').live('change', function () {
            var defects = $('#defectId');
            if ($('#categoryId option:selected').val() != '') {
    
                $.ajax({
                    data: { categoryId: $('categoryId option:selected').val() },
                    type: "GET",
                    url: '@Url.Action("\_GetDefectsByCategory", "Observation")',
                    success: function (data) {
                        defects.dataBind(data);
                        defects.reload();
                        alert("Successfully bound.");
                    },
                    error: function () {
                        alert("Failed to bind defects.");
    
                    }
                })
            };
        });
    });
    

    The alerts are there for debugging purposes, obviously. I am not natively a JScript person as I typically work in strictly OO Client-Server environments, any help would be appreciated. Cheers, --EA

    J 1 Reply Last reply
    0
    • E eddieangel

      I am sure this has been asked a million times, but I am going to ask again because I can't find a good answer to my specific issue. I am using MVC asp.net and I want to load data through Ajax when a row in a Telerik grid goes into edit mode. I can get the data to load and everything is good, but I can't get the cascading drop down to work. Here is my change event code, the error is somewhere in here:

      $(document).ready(function () {
      
          $('#categoryId').live('change', function () {
              var defects = $('#defectId');
              if ($('#categoryId option:selected').val() != '') {
      
                  $.ajax({
                      data: { categoryId: $('categoryId option:selected').val() },
                      type: "GET",
                      url: '@Url.Action("\_GetDefectsByCategory", "Observation")',
                      success: function (data) {
                          defects.dataBind(data);
                          defects.reload();
                          alert("Successfully bound.");
                      },
                      error: function () {
                          alert("Failed to bind defects.");
      
                      }
                  })
              };
          });
      });
      

      The alerts are there for debugging purposes, obviously. I am not natively a JScript person as I typically work in strictly OO Client-Server environments, any help would be appreciated. Cheers, --EA

      J Offline
      J Offline
      Jasmine2501
      wrote on last edited by
      #2

      Seems like you're missing a # in the line here:

      data: { categoryId: $('categoryId option:selected').val() },

      Should be...

      data: { categoryId: $("#categoryId option:selected").val() },

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups