You need to sign in to do that
Don't have an account?
How to add coloumn to list retrive from SOQL Query
Hi,
I had executed a soql query and put the query output in a list. Now I want to add a custom coloumn in the list.
Following is the way I am used it in code :
List<CustomObject> mylist = [select id,name,ipaddress from CustomObject];
I want to add a custom coloumn and display this all list in a table
Can anyone suggest me how to achive this???
Vf page change Like this
see the output
All Answers
Adding new column to list is same as you are adding standard field. Example)
List<CustomObject> mylist = [select id,name,ipaddress, CustomField1__c, CustomField2__c from CustomObject];
If you have to display the same in VF page then there are several ways to do like using "pageBlockTable", using apex:repeat etc.
Detail here:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_display_field_values.htm
https://salesforce.stackexchange.com/questions/161233/how-to-display-list-values-in-vf-page
Thanks,
Harsh
Hi
If you want to show a extra column then use this Code
Apex class:
Vf page:
see this code
child to parent :Is this type of queries crating separate row if inner query is giving output as multiple rows.
For example :
Your outer query based on account if there are 10 records present in account obj
and our inner queries (Contact and Opportunities) having multiple records then this query returns 10 records or more than that.
Also can you please provide output of your table for my referance.
Hi
Output of the code Is:
Inner queries will retrieve multiple records , you can see Contacts multiple
That string will be deplayed in account cloumn with heading Related Contact.
it will be like this :
----------------------------------
Account Name || Type || Related Contact
Account 1 || T2 || Contact 1 ; Contact 2
Vf page change Like this
see the output
One small question, why you created nbsp class. what is the role in this situation
Hi
No Bro ... Already nbsp class created in my org i have edited that class.
If You want exact same output use like this