2

Title says it all.

Similar to <apex:pageBlockTable first={!first} rows={!rows}/> OOTB attributes which filters rows based on index, I'm trying to find an OOTB solution for rendering only specific rows which match text filter criteria. For example: selecting Department picklist = Audit will show Audit professionals only in the pageBlockTable.

My current non-OOTB solution is to change the pageBlockTable's source list to value={!subsetList} and update a master list accordingly (whenever any textbox values or checkboxes in the table are changed).

0

2 Answers 2

1

Good question, I don't think there is OOTB solution for that.

apex:pageBlockTable just represents a Salesforce styled table. Like in HTML table you would need to do your own filtering in Server.

You can maybe use a Hierarchical custom setting which display filters out results based on specified value(s).

For better performance, Use JavaScript Remoting or Remote Objects, instead value/rerender attributes or actionSupport/function.

1
  • 1
    Just to add up another argument to @Rahul's answer. Is strongly reccommended to do that kind of filtering, server side, since that is the way in which the MVC pattern should work. The view(presented by the pageblocktable in this case), should be concerned only on printing data, not in any other logic, that decides which records to show and which not. I know, it's not your answer, but take it more as a suggestion. Feb 20, 2017 at 10:46
0

Solution is non-OOTB and EASY.

Maintain a MASTER LIST separately in the controller. And tie a subset list to the pageBlockTable VALUE="{!subsetList}".

Upon filter change (selectOption change) on the UI,

  • simply assign a new List<Wrapper/sObject>() to the subsetList
  • create a new subsetList from the master list by a for-loop and using the .add() method for master list items which are equal to the filter.

Apparently, this is a shallow copy.

(Shallow copy is immensely beneficial. Example: Inputcheckbox/inputfield changes on a FILTERED pageBlock table (value="{!subsetList}) automatically reflects in the master list variable in the controller.)

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.