1

I have a pageBlockTable that returns data from any query, in that result one of the columns returned is a picklist.

I added an InputCheckbox just above the pageBlockTable and I would like that when the user clicked on the inputCheckbox the search would be re-made considering the value of the inputCheckbox. How can I make this work without adding a search button?

Page:

<div style="float:right;">
<apex:form >
    <apex:inputCheckbox value="{!fieldFilter}" onclick="{!LoadGrid}"> 
        Check to filter
    </apex:inputCheckbox>
</apex:form>
</div>
<br />
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!results}" var="result">
        <apex:column headerValue="Name" value="{!result.name}" />
        <apex:column headerValue="Description" value="{!result.description}" />
        <apex:column headerValue="Check">
            <center><apex:inputCheckbox value="{!result.flag}" disabled="true" /></center>
        </apex:column>
        <apex:column headerValue="Created date" value="{!result.createdDate}" />
    </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>

Image of grid and filter

1

The apex:actionSupport component will help. It makes asynchronous requests to the server to get the specified part of the page re-rendered with the current data.

Use it like this:

<apex:form>
    <div style="float:right;">
        <apex:inputCheckbox value="{!fieldFilter}"> 
            <apex:actionSupport event="onchange" rerender="pageBlock"/>
        </apex:inputCheckbox>
    </div>
    <apex:pageBlock id="pageBlock">
        <apex:pageBlockTable value="{!results}" var="result">
            ...
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>

Note that at the server-side, the results content will need to be updated to match the fieldFilter property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.