You need to sign in to do that
Don't have an account?
vickySFDC
how to display dynamic sosl query results on 3 objects values in single pageblocktable in VF page?
Hi All,
I have requirement like .
I have one text box if user enters some text like 'AB' then it will search on Account,Contact and leads objects .then it shoud display values contanis 'AB' in contact, account and Lead in Single pageBlock table?
Search text: 'dynamic text' here is 'AB' then list should display like this
it should display in pageblocktable:
Objname Name City
Contact abi abudhabi
Account test AB chennai ab
Lead abraham raviab
Thanks,
Vicky
Well the tricky part is getting them in to a single list...
But given that a SOSL query returns a list<list<sObject>> then you can easily loop through that list of lists, and add it to a flat list to display somewhere else.
Given that you want to display the sObjectType in the column as well means you could create an inline class to store a result. The class would contain two properties of sObject Label, and sObject record.
Then it's a simple matter of creating a list of that custom class and displying that list on the page block table.
Here is how mine would look:
And this would be a simple VF page to consume it:
note that I am using a repeat - but you could use a pageBlockTable.
For instances where you want to render only specific fields in a column: you can use apex:outputField and use the "rendered" parameter with something like:
rendered="{!row.sObjectTypeName == 'Account'}"
All Answers
Well the tricky part is getting them in to a single list...
But given that a SOSL query returns a list<list<sObject>> then you can easily loop through that list of lists, and add it to a flat list to display somewhere else.
Given that you want to display the sObjectType in the column as well means you could create an inline class to store a result. The class would contain two properties of sObject Label, and sObject record.
Then it's a simple matter of creating a list of that custom class and displying that list on the page block table.
Here is how mine would look:
And this would be a simple VF page to consume it:
note that I am using a repeat - but you could use a pageBlockTable.
For instances where you want to render only specific fields in a column: you can use apex:outputField and use the "rendered" parameter with something like:
rendered="{!row.sObjectTypeName == 'Account'}"
Good Its working fine my requirement.
Thanks.
can someone help me