You need to sign in to do that
Don't have an account?
Bob.390672021994282E12
Visualforce Parent Child
I have two objects that I am trying to display on a screen. The parent works fine however the child records are not displaying anything.
When I place an input value on the screen the input value doesnt even display. Am I missing something?
Yes there are records associated to the parent record already.
Controller
public with sharing class ParentChild {
private ApexPages.StandardController NormalSalesforceController {get; set;}
public parent__c CurrentParentRecordId{get; set;}
public List<child__c> childrecords {get; set;} // declare the list of child records.
public ParentChild(ApexPages.StandardController NormalSalesforceController){
CurrentParentRecordId = [Select Id, Next_Step__c from Parent__c where id = :apexPages.currentPage().getParameters().get('id')];
}
public List<child__c> getUserValue() {
List<child__c> UserValue= [SELECT Id, name, Field__c, Field_2__c, User__c, Parent__c FROM child__c WHERE Parent__c =:CurrentParentRecordId.id];
return Uservalue;
}
}
<apex:page standardController="Parent__c" extensions="ParentChild" tabstyle="Account">
<apex:form >
<style>
body .bPageBlock .pbBody .red .pbSubheader{
background-color:#c00000;
}
body .bPageBlock .pbBody .blue .pbSubheader{
background-color:#0000FF;
}
body .bPageBlock .pbBody .green .pbSubheader{
background-color:#7FFF00;
}
</style>
<apex:pageBlock title="Parent">
<apex:outputPanel styleClass="red" layout="block">
<apex:pageBlockSection title="The parent Information" columns="3">
<apex:inputField value="{!Parent__c.Name}"/>
<apex:inputField value="{!Parent__c.Version_Number__c}"/>
<apex:inputField value="{!Parent__c.User__c}"/>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
<apex:pageBlock title="Child">
<apex:outputPanel styleClass="blue" layout="block">
<apex:pageBlockSection title="The child Information" columns="3">
<apex:pageBlockTable value="{!Uservalue}" var="Child">
<apex:inputField value="{!Child.Name}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
When I place an input value on the screen the input value doesnt even display. Am I missing something?
Yes there are records associated to the parent record already.
Controller
public with sharing class ParentChild {
private ApexPages.StandardController NormalSalesforceController {get; set;}
public parent__c CurrentParentRecordId{get; set;}
public List<child__c> childrecords {get; set;} // declare the list of child records.
public ParentChild(ApexPages.StandardController NormalSalesforceController){
CurrentParentRecordId = [Select Id, Next_Step__c from Parent__c where id = :apexPages.currentPage().getParameters().get('id')];
}
public List<child__c> getUserValue() {
List<child__c> UserValue= [SELECT Id, name, Field__c, Field_2__c, User__c, Parent__c FROM child__c WHERE Parent__c =:CurrentParentRecordId.id];
return Uservalue;
}
}
<apex:page standardController="Parent__c" extensions="ParentChild" tabstyle="Account">
<apex:form >
<style>
body .bPageBlock .pbBody .red .pbSubheader{
background-color:#c00000;
}
body .bPageBlock .pbBody .blue .pbSubheader{
background-color:#0000FF;
}
body .bPageBlock .pbBody .green .pbSubheader{
background-color:#7FFF00;
}
</style>
<apex:pageBlock title="Parent">
<apex:outputPanel styleClass="red" layout="block">
<apex:pageBlockSection title="The parent Information" columns="3">
<apex:inputField value="{!Parent__c.Name}"/>
<apex:inputField value="{!Parent__c.Version_Number__c}"/>
<apex:inputField value="{!Parent__c.User__c}"/>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageblock>
<apex:pageBlock title="Child">
<apex:outputPanel styleClass="blue" layout="block">
<apex:pageBlockSection title="The child Information" columns="3">
<apex:pageBlockTable value="{!Uservalue}" var="Child">
<apex:inputField value="{!Child.Name}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
may be there are no records present associated to the parent record you are referring to
apply a debug statement and check if your list is empty or no
Thanks,