function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kevin RyanKevin Ryan 

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>

Best Answer chosen by Admin (Salesforce Developers) 
squekywheelsquekywheel

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

Kevin RyanKevin Ryan

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?

squekywheelsquekywheel

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.

This was selected as the best answer