2
I am using a function to check if all checkbox are marked to load a registered already filled.
So I wanted to know how to call the function.
function selectAllCheckbox() {
var booleanArray = new Array();
var allCheckBox = $('input[id*="ufs"]');
$(allCheckBox).each(function() {
if ($(this).prop('checked') == true) {
booleanArray.push($(this).prop('checked'));
}
});
if (booleanArray.length == 27) {
allCheckBox.last().prop('checked', true);
}
}
In this I check if all checkboxes are filled, if yes, I mark the checkbox all.
<p:selectManyCheckbox id="ufs" value="#{lojaBean.pojo.ufsInss}" layout="grid" columns="4" styleClass="columnLeft">
<f:selectItems value="#{lojaBean.helper.estados}"/>
<f:selectItem itemLabel="Todos" itemValue=""/>
<p:ajax event="change" onstart="selectAll(event)" update="ufs"/>
</p:selectManyCheckbox>
I use another method selectAll(event)
to select the button, select all. I would like when loading a page, it checks if all checkbox have been filled, but do not know how to call...
Man, I was in doubt because here’s the thing, let’s assume I use the oncomplete, there’s how I mark a checkbox using my function using this event?
– Macario1983
@Macario1983 Yes. Your checkbox has to have the attribute
widgetvar
with some name. Then you can reference the field through Javascript by that name and use the functioncheck()
of the API Client Side. See the Primefaces User Guide for more details, as there you have the list of functions client of each component.– utluiz
Because the thing is, I use the page inside another... It has a main page that contains the blocks of the others, as the top, middle and lower part. Ai on this page I already call the
outputScript
. And then the implemented pages enter the middle... Understand?– Macario1983
@Macario1983 It is not better to make this logic in your method
ManagedBean
? Loading the list into the methodgetEstados()
, apply the code it definestrue
in the last item if all 27 are completed.– utluiz
Man, I’ve tried this before, but how to do with the
checkbox
ofselectItem
is marked, but it didn’t work, you have any idea how?– Macario1983