Documentation
SolutionDeveloperComplianceProjects
  • Getting Started
  • Technology
    • Application Framework
    • Object-Relational Mapping
    • Security Framework
    • Architecture Pattern
    • API Management
  • Environment
    • Development Tool
    • Database Server
    • Web Server
  • PRESENTATION
    • Design Material
    • HTML Helpers
    • Icon Images
    • Custom CSS
    • JQuery Plugin
      • DataTables
      • Tabs
      • Date Picker
      • Calendar
      • Chart
      • Treeview
    • Client Script
      • Open Modal
      • Close Modal
      • Handle return data
      • Load Content
      • Change Hash
      • Change Title
      • Get actual Hash
      • Get Content
      • Update Content
      • Delete Content
      • Get Partial Content
      • Get Partial Content Async
      • Update Partial Content
      • Update Partial Content Async
      • Delete Partial Content
      • Get Action
      • Update Action
      • Delete Action
      • Cascading Dropdown
      • Display Document
    • MVC View
  • BACKEND
    • Base Controller
    • Controller
    • Base Model
    • View Model
    • Class Utility
      • Constant Values
      • Global Properties
      • Option Helper
      • Setting Helper
    • Data Repository
      • Read Columns
      • Read All Columns
      • Read First Record
      • Read by Primary Key
      • Find Record
      • Insert Record
      • Update Record
      • Delete Entity
      • Delete by Criteria
      • Delete by Primary Key
      • Counting Record
      • Check Exist
      • Generate Row-Id
    • Unit Of Work
    • Data Entity
  • Application Features
    • Account Management
    • Navigation Editor
    • Access Control
  • Examples
    • Simple Page
    • Master Detail
    • Editor Template
Powered by GitBook
On this page
  • Syntax
  • Arguments
  • Description
  • Example
  1. PRESENTATION
  2. Client Script

Cascading Dropdown

Syntax

$.ddCascading = function (targetId, url)

Arguments

targetId

String

Dropdown that will be populated based on selection of other dropdown list of values from server specified in “url”.

url

String

URI of the action that List is derived from

Description

Populates a Dropdown List whose content/items depends on the selection of a previously selected Dropdown element by sending an HTTPGET request to the action of the URI specified in “url” and loading the data from the Server into the Dropdown List specified in “targetId”.

To be able to use this feature, the Model of the webpage needs to contain a function along the lines of:


public List<SelectListItem> GetDD2Items(D DD1Selection, string id)
{
    var dd2List = new List<SelectListItem>();
    
    ...
    
    return dd2List;
}

This function needs to be called by the respective Action in the Controller, for example like this:

[HttpGet]
public JsonResult Dropdown(D dd1, string id)
{
     var model = new Model();
     return Json(model.GetDD2Items(dd1, id), JsonRequestBehavior.AllowGet);
 }

Example

The following program illustrates the function call:

$("#Dropdown1").change(function () {
    $.ddCascading("Dropdown2", "/main/dropdown/" + $(this).val());
})

When the selection of the first Dropdown List changes, function will change the content of the second Dropdown List by sending a request to the action of the URI “main/dropdown” along with the new selection of first Dropdown List as parameter.

PreviousDelete ActionNextDisplay Document

Last updated 2 years ago