function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Frank CarterFrank Carter 

hide checkbox select all before search

Hello,
I need help on vf search page. How To do to hide checkbox select all before the search? All the column are hidden except checkbox:
User-added image
piece of code
<apex:pageBlock id="pgblk">
            <apex:pageBlockTable value="{!listBD}" var="b">
                <apex:column >
                    <apex:facet name="header">
                        <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                    </apex:facet>
                    <apex:inputCheckbox value="{!b.check_box}" id="inputId" />
                </apex:column>
                
                <apex:column value="{!b.cs.Name}"/>

Thanks.
Best Answer chosen by Frank Carter
Alain CabonAlain Cabon
Hi,

With a new variable, "listnotnull"
 
<apex:variable var="listnotnull" value="{!listBD != null}" />
<apex:pageBlockTable value="{!listBD}" var="b">
                <apex:column >
                    <apex:facet name="header" >
                         <apex:inputCheckbox rendered="{! listnotnull }"/>
                   </apex:facet> 
                    <apex:inputCheckbox value="{!b.check_box}" id="inputId" />
                </apex:column>     
                <apex:column value="{!b.Name}"/>
</apex:pageBlockTable>

 

All Answers

Alain CabonAlain Cabon
Hi,

rendered : Boolean : A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputCheckbox.htm
 
<apex:column>
    <apex:facet name="header">
        <apex:inputCheckbox rendered="{!b.check_box!=null}" onclick="selectAllCheckboxes(this,'inputId')"/>
    </apex:facet> 
    <apex:inputCheckbox value="{!b.check_box}" id="inputId" />
</apex:column>
Frank CarterFrank Carter
Hello, 
Thanks for answer. I added the instruction:
rendered="{!b.check_box!=null}"
but if I Click the search button all header column appear except the checkbox select all. Is it possible to have the select all checkbox only after  I click the search button?

Thanks
Rajesh3699Rajesh3699
Hello Frank

on click of the Search button, you have to rerender the SelectAll checkbox, use the attribute Rerender on the <apex:commandButton> tag
and specify the Id of Select All checkbox, 

<apex:inputCheckbox rendered="{!b.check_box!=null}"onclick="selectAllCheckboxes(this,'inputId')" id=allchkBox"/>

Thank You,
Rajesh Adiga P.
Alain CabonAlain Cabon
Hi,

With a new variable, "listnotnull"
 
<apex:variable var="listnotnull" value="{!listBD != null}" />
<apex:pageBlockTable value="{!listBD}" var="b">
                <apex:column >
                    <apex:facet name="header" >
                         <apex:inputCheckbox rendered="{! listnotnull }"/>
                   </apex:facet> 
                    <apex:inputCheckbox value="{!b.check_box}" id="inputId" />
                </apex:column>     
                <apex:column value="{!b.Name}"/>
</apex:pageBlockTable>

 
This was selected as the best answer
Frank CarterFrank Carter
Hello,

thanks for the answer:
I addedd the rerender to the command button:
<apex:commandButton value="Search" action="{!loadData}" reRender="allchkBox" style="text-align:left;" />
but now button doesn't search, doesn't works.

 
Rajesh3699Rajesh3699
If possible share your code, lets check.

Thank You,
Rajesh.