How can i recover all my DropDownList options? I've tried a lot of different things, but none of them worked. I don't want just the selected value, but the entire options, with it's text and value.
I tried to use $('form').serialize() and while it recover complex objects through model binding to my controller, the entire dropdownlist is lost, only it's selected value returns.
I tried even generating a json object with following structure (unsuccessfully):
var list = [
{
"MyDropDownList":
{ "option": {"Text": "Some text", "Value": "Some value"} },
{ "option": {"Text": "Ohter text", "Value": "Other value"} }
}
];
I'm really considering to create a nested object to emulate a dropdownlist, instead of using the List<SelectListItem>
Related
I am working on a creating a Slack bot (using Python Bolt) which starts with opening a modal form when invoked. We have 2 fields in the form that are select dropdown menus named as Category and Sub-Category. I want to populate the Sub-Category dropdown field according to the Category selected. I have a static JSON like :
{
"Release": {
"subcategories": [
"Release 1",
"Release 2"
]
},
"Milestone": {
"subcategories": [
"Milestone 1",
"Milestone 2"
]
},
"Code Review": {
"subcategories": [
"Code Review 1",
"Code Review 2"
]
}
}
I am able to populate Category dropdown field with options Release, Milestone, Code Review but not able to find a way to change the Sub-Category dropdown based on then selected Category. For example, if Milestone is selected by user in Category, Sub-Category dropdown should get populated with Milestone 1 and Milestone 2 dynamically.
Is it possible to achieve this using Python Bolt framework ?
P.S. : Using Jinja2 template to create block json for modal form.
We are facing one issue with Kendo UI grid. (We are evaluating it, so no license copy as of now)
Scenario is:
We need to show data in Grid component.
For each column, we will have filter in form of multi select list box (see image attached).
We tried Kendo UI trial copy, and were successful to set data in it.
When we tried setting items in filter box, they appear to be blank.
Following is JSON which provides list of items in filter:
data which should be displayed in that dropdown list
[
{
"id": 67,
"name": "Investigation ESP"
},
{
"id": 88,
"name": "Refuse & Pickups"
},
{
"id": 101,
"name": "Dead Bug Removal"
}
]
Can you share proper example or point our mistake.
please try to combine the following two things...
http://demos.telerik.com/kendo-ui/grid/filter-menu-customization
http://www.telerik.com/forums/multi-select-with-checkboxes-plugin
Has anyone done anything with AngularJS and select droplists populating another droplist on the page based on a selection.
We have a service we are populating a Select droplist with. But we have another droplist on the page that, when the first droplist's section is made, the second droplist will dynamically populate with information based on the selection of the first droplist.
JSON structure example:
[{
"Cars":{
"Type": "Hatchback",
"Type": "Sedan"
},
"Trucks":{
"Type": "Small",
"Type": "Full Size"
}
}]
So if my first <select> droplist contains options for Cars and Trucks, then based on that selection the second <select>droplist will dynamically populate with the 'Type' based on the selection of a Car or Truck.
Does anyone have any insight or point me to any tutorials based on this?
Thanks in advance
Use the option in you first selection to populate the list:
<select ng-model="d1" ng-options="key for key in vehKeys"></select>
<select ng-model="d2" ng-options="t.Type for t in veh[d1]"></select>
my controller looks like this:(I changed your format, as it was, Type would just keep overwriting its self)
$scope.veh = {
"Cars":[
{"Type": "Hatchback"},
{"Type": "Sedan"}
],
"Trucks":[
{"Type": "Small"},
{"Type": "Full Size"}
]
};
$scope.vehKeys = Object.keys($scope.veh);
I'm not entirely sure why you cannot do something like this though
<select ng-model="d1" ng-options="type for type in Object.keys(veh)"></select>
so I just did it in the controller.
I was looking for a solution that
displayed multiple columns of independent data
did not require a click (or focus) to show the list
had a simple interface
supported visible & hidden values (like HTML's <select>)
has color highlighting to show matches
automatically deletes character entries that are not in any of the choices
I wasn't able to find a control that met these requirements, so I created one. Here is an image of the control in use.
The code to create this control is:
$('input#scrolltest').menuoptions({
"Data": { 1:"January",2:"February",3:"March",4:"April",5:"May", 6:"June",7:"July",
8:"August",9:"September",10:"October",11:"November",12:"December" },
"onSelect": function(mo, data) {
console.log(mo, data.newVal, data.type );
},
"InitialValue": { 'val': 'December'},
"Height": 200,
"Sort": []
});
This control is documented here
The above example is part of this demo page
I have a dropdownlist of car brands:
#Html.DropDownListFor(
model => model.Brand,
new SelectList(
new List<Object>{
new { value = "Opel" , text = "Opel" },
new { value = "Lada" , text = "Lada" },
new { value = "BMW" , text = "BMW"}
},
"value",
"text"
As you can see, i was too lazy for making any classes, and thies code at the View.
How can i make a second dropdownlist: with car models ? I mean that user selects "Opel" and then can select "Corsa" or "Vectra" but not "X6" or "2110" ?
Looking for the most simple way to do it.
You want to make a cascading dropdown, probably using ajax.
This tutorial was almost made perfectly for you (car themed)
http://stephenwalther.com/archive/2008/09/07/asp-net-mvc-tip-41-creating-cascading-dropdown-lists-with-ajax.aspx