You need to sign in to do that
Don't have an account?
Data Table
I'm working through the Force.com tutorials and i'm tutorial 7 and everything has worked fine so far but on this tutorial i can't get the data table to populate. Can anybody help me out or point me in the right direction? Thanks
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" standardController="Merchandise__c" recordSetVar="products">
<apex:stylesheet value="{!URLFOR($Resource.Styles, 'styles.css')}" />
<h1>Inventory Count Sheet</h1>
<apex:form >
<apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even">
<apex:column headerValue="Product">
<apex:outputText value="{!pitem.name}"/>
</apex:column>
<apex:column headerValue="Inventory">
<apex:outputField value="{!pitem.Total_Inventory__c}"/>
</apex:column>
<apex:column headerValue="Physical Count">
<apex:inputField value="{!pitem.Total_Inventory__c}"/>
</apex:column>
</apex:dataTable>
<br/>
<apex:commandButton action="{!quicksave}" value="Update Counts" />
<apex:commandLink action="{!next}" value="Next" rendered="{!hasNext}" />
</apex:form>
</apex:page>
The page is associated with a standard controller, which in turn is associated with a specific object type, in this case Merchandise__c. Thus, the id associates it directly with an instance of the type associated with the controller. If the page is not specific to a type of the object, then you can write a custom controller and query the object instances yourself which is more involved.
All Answers
In order for me to get my products to show up i added ?id= and an id number of one of my merchandise items to the end of the url. This works but it doesn't make sense to add a record id to the page if you're getting all records from the object. Any ideas why this is how it works?
The page is associated with a standard controller, which in turn is associated with a specific object type, in this case Merchandise__c. Thus, the id associates it directly with an instance of the type associated with the controller. If the page is not specific to a type of the object, then you can write a custom controller and query the object instances yourself which is more involved.