1

I have a HTML table in a visualforce page with a custom controller that is fetch with data from the Lead object. I would like to filter the data using two filters The second filter values are dependent of the value previously selected in the first filter. How can I do that? Any sample code would be very much appreciated. Thank you!

2

Can you tell us more about what kind of filters you are wanting to have? Do you have any code that you can post?

Assuming your filters are actually drop down lists(Apex:SelectList), You can have the values of the second list populated based on the value selected in the first one.

Here is a simple example which shows this. http://nanostuffs.com/Blog/?p=675

You can use this same logic with any other input elements that you need.

Then you could probably have a command button which would populate(rerender) a Datatable or pageblock component with the results based on what has been selected in the two drop down lists.

More ideas on filtering datatables:

http://boards.developerforce.com/t5/Visualforce-Development/Visualforce-Email-How-to-filter-datatable/td-p/244281

Very cool but advanced example of a dynamic datatables using JQuery. http://macscloud.com/dynamic-datatables-with-jquery-and-visualforce/

  • Thanks a lot Richard! As you well assumed, my filters are drop down list. The link you gave me (nanostuffs.com/Blog/?p=675) is exactly what I need! :) – Chicho Jul 9 '13 at 13:06
  • Np Chico. If you thought this answered your question, Please mark it as such so others who search for something similar can find this as well. Thanks. – Richard N Jul 11 '13 at 19:52

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.