You need to sign in to do that
Don't have an account?
datatable with account and parent account
i have datatable with columns
1.account name 2.childs of account
--- ---
--- ---
in first column all account names and secound column should consists child record names(parent account)
i am unable to write soql query to retrieve child records
i wrote below code:
vf:
================================
<apex:page standardController="account" sidebar="false" recordSetVar="acc" extensions="getchilds">
<apex:form >
<apex:pageBlock >
<apex:dataTable bgcolor="silver" border="2" value="{!acc}" var="a" cellspacing="10" cellpadding="5">
<apex:facet name="header">List of account along with childs</apex:facet>
<apex:column >
<apex:facet name="header">parent</apex:facet>
<apex:outputText value="{!a.name}"/>
</apex:column>
<apex:column >
<apex:facet name="header">childs</apex:facet>
<apex:outputText />
</apex:column>
<apex:column >
<apex:facet name="header">phone</apex:facet>
<apex:outputText value="{!a.phone}"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>
class:
==============
public class getchilds {
list<string> child=new list<string>();
public getchilds(ApexPages.StandardSetController controller) {
child=[select name from account where id=parentid];
}
}
Hi
Try this
public class getchilds {
list<Account> child=new list<Account>();
public getchilds(ApexPages.StandardSetController controller) {
child=[select name ,ParentId from account where ParentId !=null];
System.debug('############Child records##########'+child.size());
}
}
you can check in your debuglog about number of child account records .
Did this post answers your issue if so please mark it solved
Thanks
asish