You need to sign in to do that
Don't have an account?
Rick Roll
Hi everyone!
I have an object Pattern__c with 3 fields.
I want to retrieve the records from Pattern Name(Name) into a selectlist with no duplicates like shown above (I only made it with html).
After choosing the value of the picklist and clicking the button, the pageblocktable should only show the categories under that Pattern Name.(mine shows all at the moment)
ex. selecting Pattern A should only show 3 rows in the pageblocktable
heres what I did:
Page
Retrieving records from custom object into picklist and show dynamic table
Hi everyone!
I have an object Pattern__c with 3 fields.
I want to retrieve the records from Pattern Name(Name) into a selectlist with no duplicates like shown above (I only made it with html).
After choosing the value of the picklist and clicking the button, the pageblocktable should only show the categories under that Pattern Name.(mine shows all at the moment)
ex. selecting Pattern A should only show 3 rows in the pageblocktable
heres what I did:
Page
<apex:page sidebar="false" controller="GetPattern"> <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"/> <apex:includeScript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" /> <div class="row"> <div class="col-md-4"> <apex:pageBlock title="Pattern"> <apex:form> <select> <option disabled="true">Select Pattern</option> <option>Pattern A</option> <option>Pattern B</option> <option>Pattern C</option> </select> <input type="button" value="Process"/> </apex:form> </apex:pageBlock> </div> <div class="col-md-8"> <apex:pageBlock title="Pattern Summary"> <apex:pageBlockTable value="{!categorylist}" var="cat"> <apex:column headerValue="Category A" value="{!cat.CategoryA__c}"/> <apex:column headerValue="Category B" value="{!cat.CategoryB__c}"/> </apex:pageBlockTable> </apex:pageBlock> </div> </div> </apex:page>class
public class GetPattern{ public List<Pattern__c> categorylist {get; set;} public GetPattern() { this.GetRecords(); } public void GetRecords() { categorylist = [select Name,CategoryA__c,CategoryB__C from Pattern__c]; } }How do I do these things?
You Can try below full solution :-
Page Should be :-
Class Should be :-
Test Class Should be :-
You can check Test class best pratice on below post :-
http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html
http://amitsalesforce.blogspot.in/2015/06/salesforce-testing-best-practice.html
Apex best Pratice at below post:-
http://amitsalesforce.blogspot.in/2015/06/trigger-best-practices-sample-trigger.html
Please mark this as solution if this will help you. So if some one has same issue this post can help others.
Thanks
Amit Chaudhary
All Answers
Please try below code. I hope that will help you:-
Class should be :- Page Should be:-
Please mark this as solution if this will help you.
Thanks,
Amit Chaudhary
amit.salesforce21@gmail.com
Thanks for spending time in providing some good code. I added id="cases_table" to the pageBlock and it worked great. My only concern is that you statically added options which was one of my main concerns that's why I asked for help (I read most examples were also static) and I need it to be dynamic (from the Pattern__c : Name) with no repeating values on selectlist if possible.
class
-------------------------------------
Page
-----------------------------------
1. A test class for your code (I don't get much of it yet so it'll be hard for me to build one)
2. How do I disable the Select in the selectlist? jquery?
try replacing line 12 of my class with below line
You Can try below full solution :-
Page Should be :-
Class Should be :-
Test Class Should be :-
You can check Test class best pratice on below post :-
http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html
http://amitsalesforce.blogspot.in/2015/06/salesforce-testing-best-practice.html
Apex best Pratice at below post:-
http://amitsalesforce.blogspot.in/2015/06/trigger-best-practices-sample-trigger.html
Please mark this as solution if this will help you. So if some one has same issue this post can help others.
Thanks
Amit Chaudhary