lundi 18 janvier 2016

I have filled 3 dropdowns (Type List

My question is how can i cascade those dropdowns so that when i choose in first dropdown some value i get second dropdown, and when i choose value in that second dropdown i get shown third dropdown

ViewModel:

    {
        List<KeyValuePair<string, int>> typeList = new List<KeyValuePair<string, int>>();

        foreach (var building in buildings)
        {
            if (building == 13)
            {
                typeList.Add(new KeyValuePair<string, int>("Airport City - Building 1300", (int)Buildings.Zgrada1));
            }
            else if (building == 15)
            {
                typeList.Add(new KeyValuePair<string, int>("Airport City - Building 1500", (int)Buildings.Zgrada2));
            }
            else if (building == 31)
            {
                typeList.Add(new KeyValuePair<string, int>("Novi Sad Development Centar", (int)Buildings.Zgrada3));
            }
        }
        return typeList;
    }


    {
        List<KeyValuePair<string, int>> designZonesFor1300 = new List<KeyValuePair<string, int>>();

        designZonesFor1300.Add(new KeyValuePair<string, int>("O", (int)DesignZones.O));
        designZonesFor1300.Add(new KeyValuePair<string, int>("Avisto", (int)DesignZones.Avisto));
        designZonesFor1300.Add(new KeyValuePair<string, int>("TES", (int)DesignZones.TES));

        return designZonesFor1300;
    }

    private List<KeyValuePair<string, int>> CreateDesignZonesForBuilding1500()
    {
        List<KeyValuePair<string, int>> designZonesFor1500 = new List<KeyValuePair<string, int>>();

        designZonesFor1500.Add(new KeyValuePair<string, int>("O", (int)DesignZones.O));
        designZonesFor1500.Add(new KeyValuePair<string, int>("Elsys", (int)DesignZones.Elsys));
        designZonesFor1500.Add(new KeyValuePair<string, int>("Altera", (int)DesignZones.Altera));
        designZonesFor1500.Add(new KeyValuePair<string, int>("ST", (int)DesignZones.ST));
        designZonesFor1500.Add(new KeyValuePair<string, int>("Texas Instruments", (int)DesignZones.TexasInstruments));

        return designZonesFor1500;
    }

Controller:

    {
        List<int> buildings = new List<int>();

        buildings.Add(13);
        buildings.Add(15);
        buildings.Add(31);

        OfficeLocationReportViewModel viewModel = new OfficeLocationReportViewModel(buildings);

        return PartialView("~/Views/Report/_OfficeLocationReportFilterings.cshtml", viewModel);          
    }

View:

    <div>
        @Html.DropDownList("officeLocationBuildings", new SelectList(Model.ListOfBuildings, "Value", "Key", 1), "-- Select Building --")
    </div>

    <div>
        @Html.DropDownList("officeLocationDesignZones", new SelectList(Model.DesignZonesForBuilding1300, "Value", "Key", 1), new { @class = "dropdown1" })
    </div>

I want second dropdown to generate values and show itself when i choose value in my first dropdown

Aucun commentaire:

Enregistrer un commentaire