0

I made a < apex:reapeat> tag within a table and I want to use rendered to display or not values from a list, base on an input search.

The problem is if I have 5 values in the list for example:

example 1

example 2

example 3

example 4

example 5

And I enter 5 to the search input - I will get 4 empty rows and my value will be display still in its 5th place :

""

""

""

""

example 5

Its happening with PageBlockTable also.

any Idea?

my code :

 **"ProdName" - having the value of the text input**

<table class="table">
              <apex:repeat value="{!productoList}" var="plist" >
        <tr>

          <td>
             <apex:outputPanel rendered="{! AND(act!=null,contains(plist.label,prodName))}">
             <apex:commandLink value="{!plist.label}" action="{!checkTheValues}">

               <apex:param value="{!plist.value}"  name="productSelected" />
               <apex:param value="{!plist.label}"  name="productSelectedLabel" />

                  </apex:commandLink>

                </apex:outputPanel> 

            </td>




       </tr>

    </apex:repeat>
</table>

Thanks!

  • So, you want to display all the 4 rows with blank as well as the value in the fifth row? – Santanu Boral Apr 3 at 10:51
  • when I click on the search input all the list is shown, one under other like it should be. But when I use the "filter" by pressing on a letter, Like in the example - "5" I want only "example 5" will be shown but in the first row – Salvation Apr 3 at 10:54
2

This is happening because your tr's are rendering although the components within it are not rendered. To fix this, you will have to hide the tr's as well.

You can do it using style attribute of tr i.e. conditionally display the tr's using below code

<tr style="{!IF(AND(act!=null,contains(plist.label,prodName)), '','display:none')}">

so, your visualforce page will be

<table class="table">
      <apex:repeat value="{!productoList}" var="plist" >
        <tr style="{!IF(AND(act!=null,contains(plist.label,prodName)), '','display:none')}">
            <td>
                <apex:outputPanel rendered="{! AND(act!=null,contains(plist.label,prodName))}">
                    <apex:commandLink value="{!plist.label}" action="{!checkTheValues}">
                        <apex:param value="{!plist.value}"  name="productSelected" />
                        <apex:param value="{!plist.label}"  name="productSelectedLabel" />
                    </apex:commandLink>
                </apex:outputPanel> 
            </td>
        </tr>
    </apex:repeat>
</table>
  • GREAT! Thanks! - just fixed the tr style - plist with plist.label and it works! Thank you! – Salvation Apr 3 at 11:43
  • Great ! Updated that part in the answer – Vijay Ganji Apr 3 at 11:45

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.