In my controller I query for leads and accounts to display them in a googlemap and also in a panelGrid:
However what I fail to achieve is to display the leads and accounts in the same panelGroup and not 2 single ones
public List<Lead> warehouses {get; private set;}
public List<Account> Pot {get; private set;}
So far I have 2 seperate queries. One for 'warehouse' (leads) and one for 'Pot' (accounts) - (here a snippet)
warehouses = [
SELECT Id,Street,company, Name,
FROM Lead
WHERE DISTANCE(LocateCity__c, GEOLOCATION(:dlat,:dlon), 'km') < :decimal.valueof(myInput)
ORDER BY DISTANCE(LocateCity__c, GEOLOCATION(:dlat,:dlon), 'km')
LIMIT :recordLimit
];
pot = [
SELECT Name,ShippingCity,ShippingPostalCode
FROM Account
WHERE DISTANCE(LocateCity__c, GEOLOCATION(:dlat,:dlon), 'km') < :decimal.valueof(myInput)
ORDER BY DISTANCE(LocateCity__c, GEOLOCATION(:dlat,:dlon), 'km')
LIMIT :recordLimit
];
Since I do not know any better I created for each an apex:PanelGrid in my visualforce page:
To Display Leads:
<apex:pageBlockSectionItem >
<apex:outputPanel styleClass="container-fluid">
<div style="height:300px; overflow:auto !important;">
<apex:repeat value="{!warehouses}" var="war">
<apex:panelGrid columns="2" columnClasses="col1, col2">
<apex:panelGroup >
<apex:variable var="url" value="GoogleDistance | https://www.google.com/maps?saddr=+
{!currentAccount.Geolocation__c}&daddr=+{!war.Geolocation__c}" />
<apex:outputLink rendered="{!IF(NOT(CONTAINS(selectedField,'Jobads')), true, false)}" value="
{!MID(url, FIND('|', url) + 1, LEN(url))}" target="_blank">{!distances[war.id]}</apex:outputLink>
</apex:panelGroup>
</apex:panelGrid>
</apex:repeat>
</div>
</apex:outputpanel>
</apex:pageBlockSectionItem>
To Display Accounts:
<apex:pageBlockSectionItem >
<apex:outputPanel styleClass="container-fluid">
<div style="height:300px; overflow:auto !important;">
<apex:repeat value="{!pot}" var="pote">
<apex:panelGrid columns="2" columnClasses="col1, col2">
<apex:panelGroup >
<apex:variable var="url" value="GoogleDistance | https://www.google.com/maps?saddr=+
{!currentAccount.Geolocation__c}&daddr=+{!pote.Geolocation__c}" />
<apex:outputLink rendered="{!IF(NOT(CONTAINS(selectedField,'Jobads')), true, false)}" value="
{!MID(url, FIND('|', url) + 1, LEN(url))}" target="_blank">{!distances[pote.id]}</apex:outputLink>
</apex:panelGroup>
</apex:panelGrid>
</apex:repeat>
</div>
</apex:outputpanel>
</apex:pageBlockSectionItem>
I have read some articles about wrapper classes but struggle to adapt this to my problem.
Can anyone point me in the right direction? To put leads and accounts in the same panelgrid instead of 2 seperate one for each objects?
Thanks!