+ Start a Discussion
javierjiesjavierjies 

Trying to do a simple table!

Hello everyone!!

 

I have an object called Noticia__c and, when I try to do my first VF Page, where I could see all the fields of Noticia__c, I do this but I get nothing!!

 

 

<apex:page showHeader="false" standardcontroller="Noticia__c">

                    <apex:pageBlock id="result" title="Noticias">
                        <apex:pageBlockTable value="{!Noticia__c}"  var="item">
                             <apex:column value="{!item.Cuerpo__c}"/>
                             <apex:column value="{!item.Titulo__c}"/>
                        </apex:pageBlockTable>
                     </apex:pageBlock>

 </apex:pag>

 

 Am I doing something wrong? Can I do it without doing a Class??

 

Thanks in advance!!

JimRaeJimRae

You need to pass an ID for your object in the URL, are you doing that?

 

something like https://na1.salesforce.com/apex/myNoticia?id=xxxxxxxxxxxxxxx

 

Hope that helps.

 

javierjiesjavierjies

Hi!

 

Thanks for your fast response!

 

Actually, I want to show all the fields Cuerpo__c from the table Noticias__c!!

 

 

JimRaeJimRae
So, is Cuerpo__c a related object?  How is it related and could their be more than one?
javierjiesjavierjies

I have an object called Noticia__c (News in english) where I have I field called Cuerpo__c (Body in english)

 

So, I have 50 records in the object, and I  want to show the 50 entries of field Cuerpo__c

 

Sorry for the misunderstanding

 

Thanks!!

JimRaeJimRae

You need to create a sub table for the related item.

 

Something like this, you will need to supply the appropriate field names on the Cuerpo instead of the xxxxx:

 

<apex:page showHeader="false" standardcontroller="Noticia__c"> <apex:pageBlock id="result" title="Noticias"> <apex:pageBlockTable value="{!Noticia__c}" var="item"> <apex:column value="{!item.Titulo__c}"/> <apex:pageblocktable> value="{item.Cuerpo__c}" var="cuerpo"> <apex:column value="{!cuerpo.xxxxx}"> <apex:column value="{!cuerpo.xxxxx}"> </apex:pageBlockTable> </apex:pageBlockTable> </apex:pageBlock> </apex:page>

 

 

 

javierjiesjavierjies

I'm sorry but I can't follow you...

 

What's exactly xxxx? I mean, Cuerpo is a field (textarea) inside of the object Noticia__c, and I don't know what attributes can I obtain from It

 

 Thank you for your help!

 

 

 

JimRaeJimRae

Sorry for the misunderstanding, I thought when you said that Cuerpo__c had 50 items, it was a related list.

Sounds like it is a large textarea.

 

Not sure, does it work if you exclude that field, and show the other fields?

Just trying to narrow the issue down.

 

 

 

 

 

ColinKenworthy1ColinKenworthy1

Do you mean you created a Noticia__c table and created 50 records on it. Now you just want to list the 50 records in a VF page table as if you had done a 'list all' ?

 

Each record contains a text (Titulo__c) field and textarea (Cuerpo__c) field. That's the way I'm reading it.

ColinKenworthy1ColinKenworthy1

Hi Javier

This should work, the only thing you are missing it the recordSetVar in the <apex: page tag, then you need to reference it in the pageBlockTable tag.

 

 

<apex:page showHeader="false" standardcontroller="Noticia__c" recordSetVar="NewsItems">

<apex:pageBlock id="result" title="Noticias">

        <apex:pageBlockTable value="{!NewsItems}"  var="item">

            <apex:column value="{!item.Cuerpo__c}"/>

            <apex:column value="{!item.Titulo__c}"/>

        </apex:pageBlockTable>

    </apex:pageBlock>

</apex:page>