md-option within md-select Angular Material 2.0.0 beta 10 - angular4-forms

Select All option for selecting all the values in md-option with in md-select. I am populating md-option by using ngFor and i am using formControl. I can see the checkboxes for all the md-option values. But I am not able to check all the checkboxes from typescript(.ts) file. How do put select all option?
I am trying control.setValue(arrayvalues); But it doesn't check the checkboxes.

I wrote [compareWith] = compareById(obj1, obj2) attribute for md-select in my HTML page and in the .ts file write the below method {compareById(obj1, obj2){ return obj1 = obj2.code}
}. It works for me.

Related

icefaces 1.8.2: update a table with many selectOnemenu depending on a selectOnemenu

I have a ice:selectOneMenu with a list of cars. I need that, when I select a car, an optionals table with many selectOneMenu is updated and default values are automatically selected.
So:
Cars: <select>
Optionals Table
-----------------------
Colors: <select>
Engines: <select>
Seats: <select>
Interior Color: <select>
...
...
The problem is thatI change the Cars value but the table is not updated and its values are not selected
So I want that:
if I select a Ferrari car, in the optionals table: the red color is automatically selected, the 3902CC engine is automatically selected, etc.
if I select a Porche car, the white color is automatically selected, the 616/16 engine is automatically selected,etc.
I'm using icefaces 1.8.2 and probably I can not use an ajax tag.
How can I do?
Thanks!!
I've found a workaround solution. Using:
JavascriptContext.addJavascriptCall(FacesContext.getCurrentInstance(),javascriptCodeString);
to add Javascript code to the page.
The string javascriptCodeString must contain a Javascript code that use CSS classes to bind a click event to an hidden <ice:commandButton styleClass="updateFieldsCommandButton" ... > that will call an action (for updating fields values):
function updateFields() {
document.getElementsByClassName('updateFieldsCommandButton')[0].click();
}
var listOfFields=document.getElementsByClassName('fieldToBeUpdated');
for(var i=0,len=listOfFields.length;i<len;i++) {
listOfFields[i].addEventListener('change', updateFields);
}
This works with icefaces 1.8.2 without needing an ajax tag.

zend add checkbox to multi checkbox

I'm looking to do the equivalent of
$element->addMultiOption('value', 'text');
which works for multi select dropdowns.
I can't seem to figure the equivalent is fro multi checkboxes.
try something like this:
$multichekboxElement = new Zend_Form_Element_MultiCheckbox("name_for_your_multicheckbox");
$multicheckboxElement->addMultiOption(1,'text-1');
$multicheckboxElement->addMultiOption(2,'text-2');
$multicheckboxElement->addMultiOption(3,'text-3');
$multicheckboxElement->addMultiOption(4,'text-4');
Then you just have to add the *"multicheckboxElement" variable to your Form as normal.
Their is no difference between
$element->addMultiOption('value', 'text');
For multiCheckbox elements and multiselect elements.
Error was cause elsewhere

Div not showing on change in coffeescript

I want to hide an option in my form unless a specific option is selected but my coffee script doesn't seem to work. It looks like:
jQuery ->
$('.input.boolean.optional').hide()
selected = $('#stand_type :selected').text()
value = "Microphone"
$('#stand_type').change ->
$('.input.boolean.optional').show() if selected is value
This code compiles correctly. Yes I am aware of the IDs and class selectors, they are different in the code as I'm using simple_form which only gives a div a class this is why when hiding it I'm using a class not an ID. The html for my form looks like.
The logic in your script is wrong. Your checking for the value before its updated so it will always be empty your script should look like this:
jQuery ->
$('.input.boolean.optional').hide()
value = "Microphone"
$('#stand_type').change ->
selected = $('#stand_type :selected').text()
$('.input.boolean.optional').show() if selected is value

Populating some fields after selecting the element using Struts2-Dojo autocompleter

I am using sx tag i.e. struts-dojo-tag of struts 2 to autosuggest one field on one page. It is working fine. Now I want to populate other fields on the same page based on the selection of autosuggest field. I tried calling javascript on the above field on various events like onselect, onchange,etc with no success.
JSP code :
<sx:autocompleter autoComplete="true" listKey="id" listValue="brandName" name="brand.brandName" id="brandName" cssClass="textfield" list="brandList" onchange="populateInfo(this.value);"></sx:autocompleter>
here I want to autosuggest brandNames available and on selecting the brand, I want to populate data regarding the brand in some others fields. I tried calling java script function populateInfo(), but the function is not getting called.
Can you please help me out?
I think this problem can be solved by using select tag of struts2-jquery.
You can have a look in these showcase

Get/Set Checkbox and Radio Button values using Prototype

Prototype is great, but with the 1.6.1 release, the library still doesn't allow getting/setting of grouped inputs (checkboxes and radio buttons.) I'd like a way to get an array of selected values with $F($("form").checkboxes). I'd like to be able to set those checkboxes to an array of values, on the flip side.
Ideas?
You can always do something like this: (assumes you have your checkboxes have a class of checkboxes).
var checkedList = [];
$$('.checkboxes').each(function(ele){
if( $(ele).checked )
{
checkedList.push($(ele).name);
}
});
edit - just realised i misread the question, code below only good for setting values:
var form = $('options');
checkboxes = form.getInputs('checkbox');
checkboxes.each(function(e){ e.checked = 0 });
// or even checkboxes.invoke('checked',0);
could maybe use something like this though:
var cels = new Array();
$$('checkbox[checked="checked"]').each(el){
cels.push(el.value);
}
This is only for radio buttons, but still useful.
Get
$$('input:checked[name="radio_name"]')[0].value
Set
$$('input[name="radio_name"][value="to_select"]')[0].checked = true
"radio_name" is the name of your radio group. "to_select" is whichever value you want to select. The "[0]" works because only 1 radio button can be checked at a time.
On a side note, I kinda don't like prototype. A lot easier in jQuery, but you gotta use what you gotta use.
I ended up writing my own extensions to Prototype to do this. You can see them on Github. Here's a note from the project:
"These extensions allow you to use Prototype’s convenient $F() syntax to get and set the values of these grouped input elements. They’ve been tested with Prototype 1.6.0.3 and 1.6.1. There are other bits in these extensions as well. See the README.html file for more details."
The answers from seengee and Los are much appreciated, but I wanted a more integrated solution that would allow me to work with checkboxes and radio buttons with the natural $F() syntax that I already use with other form elements.
Given HTML:
<label><input type="radio" id="choiceA" name="choices" value="A" checked="checked" /> A</label>
<label><input type="radio" id="choiceB" name="choices" value="B" /> B</label>
This does a CSS styles query and returns the value for all of the elements.
$$('input:checked[type="radio"][name="group-name"]').pluck("value");