Material.css select all option within the multiselect element - select

Can anyone suggest a link or solution to add select All option within the multiselect dom element of the material design. I want all the options to be selected except for the select all option and want to display it in the text field and post it.
I couldn't find a solution for it. Can anyone suggest.
Pls Note: I dont want to add it as a button outside the dom.
$("#all_member").change(function(){
if($("#all_member option[value=-1]:selected").length > 0){
$('#all_member option').attr('selected', "selected");
$('#all_member').prev("ul").find("li").addClass('active');
$('#all_member').prev("ul").find("li span input").attr('checked', "true");
}else{
$('#all_member option').attr('selected', "false");
$('#all_member').prev("ul").find("li").removeClass('active');
$('#all_member').prev("ul").find("li span input").removeAttr('checked');
}
Thanks IN advance!

I can provide the logic. The rest is up to you.
Put an onChange event handler (function) for your select.
On that function, put an "if statement" to check if the value is equal to the value of "Select All" option.
If it returns true, then manually call the element and set its value to the value of all the other options (probably an array).

Related

Angular 2 - Dynamic Reactive form with Radio Inputs build with FormBuilder, FormGroup, FormArray

Case:
I have an array of answers which I want to show in the view as radio inputs. When one of the answers is already answered it must be [checked] and if it's [checked] a textarea shows, so far so good.
Next I want to check another radio input and I want the current selected to be deselected and its textarea hidden, then the new selected radio input should be [checked] and it's textarea should show.
I use the FormBuilder and FormArray and have following issues.
I can't use index without intrapolation, I see many examples where the index is used without.
If I select another radio input, first my data disappears and it's not checked and on the second click it get's checked but now both are checked.
- I don't have access to the checked event, I can show it in the view with {{tempVar.checked}} as you can see above, if I use a template variable #tempVar, but I don't have access to it in the textarea below *ngIf="tempVar.checked". If I do use it in the ngIf I get the following error
Expression has changed after it was checked. Previous value: 'false'. Current value: 'true'.
Questions:
Is this the right approach?
An example of a Reactive Dynamic form with FormBuilder and FormArray with Radio inputs
Here is my code
https://gist.github.com/webwizart/121c85a0f316f47977cc0c99455af7bf
I would think using the tags should be reserved for unique identifiers? I wouldn't be surprised if dom renderer will update all elements with the same id.
Not sure if this will help, but you could use an answer view model instead (containing the same data) but that also has a 'checked' property
This way you can be sure that it will behave as you would expect.
e.g.: (in your component.ts)
let answers = this.question.Question.PossibleAnswers
.map(a =>
{ return Object.assign({}, a, { checked: false });
}
);
then in html you use: 'answer.checked' instead of 'radio.checked'
ps: also you could use ng-container instead of span, so you don't have an extra DOM imprint in your html

Remove "empty" selection from dropdown list box

When creating a form in Orbeon Form Builder, you can define a list of values for a dropdown list box.
When running the form in form runner, is it possible to remove the "[Select...]" value from this dropdown list box?
I would like to restrict the possible values only to the given ones and restricting the user from selecting an "[Select...]" value when filling in the form. I hope you understand what I mean :)
Here is a screenshot
It's not possible without changes to Orbeon Forms to remove the empty option.
The best way to achieve what you want is to make the field required. When that's the case, the user will have to select a value or validation won't pass.
(The rationale for adding/keeping an empty option at the top is to force the user to make a selection. Otherwise it is possible that users might not even look at the option selected by default, and involuntarily select an incorrect option.)

why setSelection doesn't work in ComboViewer?

I have a combo, with a comboViewer in Jface,
and because is an update record dialog, I wan to sel the combo with correct selection.
I'm tryin to use
//Seleccionar Protocolo
if (fcruza.getTipoCosecha() != null)
comboProtocoloViewer.setSelection(new StructuredSelection(fcruza.getTipoCosecha()));
But the combo is not selected.
I follow java code, but I can't figure out what i'm doing wrong.
Also I have this on this control:
comboProtocoloViewer = new ComboViewer(comboProtocolo);
comboProtocoloViewer.setContentProvider (new ArrayContentProvider());
comboProtocoloViewer.setLabelProvider (new ProtocoloLabelProvider());
comboProtocoloViewer.setInput(tipoCosechaController.obtenerTipoCosecha());
Any sugestion.
Best regards
Yes ArrayContentProvider works with lists. Have you tried selecting an element as I posted earlier?
You have to make sure the element you are trying to select is part of the list, equals() of the element (fcruza.getTipoCosecha()) needs to match one of the input list.

Zend: Form Validation After AJAX

I have a form done with Zend. I load it with ajax in a dialog. It has 2 selects. Depending on what is selected in the first select, it loads the content of the second one. However, when I submit the form I get a validation error because the options of the second form weren't there at the time of creating it.
Is there a way to fix this "issue"? It does what it needs to do but I don't want it to verify that field anymore. Any way to specify that I don't want that?
You can disable the inArray validator. When constructing the form's select element, set
'registerInArrayValidator' => false
Also, a different solution would be to overload the isValid method, inspect the selected option for the first select element and then populate the options for the second element. Then call parent::isValid to check if the form is in fact valid or not.

How to set checkbox on JQGrid Add Form to checked

I'm using the Add Form to add records to my JQGrid. One of the fields is a checkbox. Does anyone know how to have the checkbox to be defaulted to checked when the form displays. I thought it would use the onInitializeForm event and the setCell method but I'm having no luck. Thanks.
Found it:
beforeShowForm: function(eparams) {
document.getElementById('calc_next_svc').checked = 'true';
}
}, // add options