Angular JS, AJAX calls on select to fill in another select - ajax

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.

Related

How to set specific fields input class manually in 'Laravel's Voyager'?

I am setting up an inventory app using the Voyager library, and want to add input classes for specific fields from $row->field. How to set it up in the edit-add blade file?
unfortunately it's not possible to add classes to BREAD fields yet. but actually there is an alternative way to achieve what you willing:
you can add an ID to field's container using BREAD display option
just goto bread > MODEL > edit > ATTRIBUTE and change its option details to
{
"display": {
"width": "3",
"id": "custom_id"
}
}
click Submit and it's done.

Kendo UI Grid - Checkbox filter issue

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

Angulajs dynamic form data with dynamic layout

I have a form which is built as a directive. I am providing the data for layout in my controller.
MyController.js
[{
"type":"selectbox",
"name":"name_one",
"label":"Name One"
}]
This data is then passed to my form_directive which then loads the template.
Then I am getting the actual data to be populated from an ajax call, inside MyController.js
eg:
$http.get('url/location').success(function(data) {
}).error(function(data) {
});
The data that is coming from the ajax will be like this:
[{
"id":"090986735",
"name":"option_1"
},{
"id":"78645679",
"name":"option_2"
}]
Now my question is how to bind this data to the selectbox?
Please note that there will be many such controls. But I have shown only one select box
Try to change the model of select.
https://docs.angularjs.org/api/ng/directive/select - the example with colors should be useful for you.

A control to optimize data entry

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

Retrieving entire DropDownlist

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>

Resources