You need to sign in to do that
Don't have an account?
Apex Table with multiple record types..
Hello..,
I have a custom object and it has 3 record types .., say apple, banana, and orange..,
I have 2 fields in each corresponding record type say ap_cost, ap_color for apple and ba_cost, ba_color for banana.., similarly for orange..,
Now i want to dispaly in a grid having like
fruits cost color
apple value value
banana value value
orange value value
and it has to be dynamic as i may have more records with same data type .., say i can have two records for apple in that object .., Quick reply is highly appreciatble..,
Thanks,
Lucky.
Yayyyyyyyyyy!!!!!!!!!!!!!!!!!!!!! Got It ...,
First of all Thank you so much @Prakash Purswnani
for your idea and with the outline.., with few edits and few changes got the solution.. :)
here goes the vf page:
and Controller extension code:
with the above code i got the solution..,
Thanks again @Prakash Purswnani
Thanks,
Lucky.
All Answers
Sorry, I am not able to get the question properly. How does recordtype is stopping you from displaying the records.
Just create a main list of the custom object and write 3 SOQL with different RecordtypeId in WHERE condition. Add up all the records in the main list and display on the VF page with the help of repeat or pageblocktable
Hi Prakash..,
Thanks for your reply..,
i do have totally 6 fields in that custom object.., say apple_cost, apple_color , banana_cost, banana_color and orange_cost, orange_color .., ok?
i will display apple_cost, apple_color fields in apple record type only .., and banana_cost, banana_color in banana record type only..., similary remianing two in orange record type.., ok?
now i want total consolidated view in a grid like as shown ..,
Fruits cost color
Apple apple_cost apple_color
banana banana_cost banana_color
orange orange_Cost orange_color
the problem here is i was using apex:column and page block table .., so i need to diplay differnt fields in single column for different record types ..., i could nt get it .., understood? is there any solution for this scenario...?
THanks,
Lucky.
Fruits cost color
fruit type fruit cost fruit color
In the controller You can retrieve data based on fruit type and get values of fruit cost ,fruit color and display in the page based on fruit type. If fruit type is Apple have a condition to display apple related data. Similarly other two.
Recordtypes are different but the Object is same.
//Apex
List<objectname> mainList=new List<objectname>();
List<objectname> appleList=[SELECT apple_cost, apple_color FROM objectname WHERE RecordTypeId='xxx'];
List<objectname> bananaList=[SELECT banana_cost, banana_color FROM objectname WHERE RecordTypeId='xxx'];
List<objectname> orangeList=[SELECT orange_cost, orange_color FROM objectname WHERE RecordTypeId='xxx'];
mainList.addall(appleList);
mainList.addall(bananaList);
mainList.addall(orangeList);
If you want in specific order like apple,banana,orange,apple,banana,orange.. then you have to play with the above list
//VF page
<apex:pageBlockTable value="{!mainList}" item="item">
<apex:column value="{!item.Name}"/>
<apex:column value="{!if(item.Name=='Apple',item.apple_cost,if(item.Name=='banana',item.banana_cost,if(item.Name=='Orange',orange_cost,false)))"/>
similarly for color
I would suggest to keep three fields in the object Name,Cost and Color. Anyways Name is different so your requirement will be achieved.
</apex:pageBlockTable>
@Prakash Thank you so much for your patience and for replying me with outline..,
I tried your solution.., like this..,
vf page:
and in controller extension class:
but
I am getting an error called " Error: DisplayRecordTypes Compile Error: unexpected token: ')' at line 19 column 25 " i.e.., [in
mainList.addall(appleList); ]
So I dont know where i am going wrong.., and if possible try to get code corrected in maps and is there any possible to get dynamically other than hardcoding in vf page? y because in future i may have new services ( in this case Fruits) .., so it would be helpful if i can make dynamic?
Thanks,
Lucky.
It's looking correct, I don't know why you are getting this error. I checked the syntax, it's working on my side. Please check the semi colons once again.
For dynamic adding, you should not create 3-3 fields for all the fruits. Just create 3 fields (1-dropdown with fruits name, 2-Cost and 3-Color)
Yayyyyyyyyyy!!!!!!!!!!!!!!!!!!!!! Got It ...,
First of all Thank you so much @Prakash Purswnani
for your idea and with the outline.., with few edits and few changes got the solution.. :)
here goes the vf page:
and Controller extension code:
with the above code i got the solution..,
Thanks again @Prakash Purswnani
Thanks,
Lucky.