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
ab84ab84 

Displaying records in a matrix on a custom VF page

I have a custom object.  It has fields for region, status and created date and there are 5 records created every day.  I want a VF page that displays this as a matrix.  

Along the top I want days, and on the side region.  The cell should display the status field.

Example:

                     apr 24   apr 25     apr 26    apr 27    apr 28
UK                Yes       No          Yes       No         Yes
US                Yes       No          Yes       No         Yes
Europe          Yes       No          Yes       No         Yes

Is there an easy way to create this kind of a matrix in VF? 
TeksajoTeksajo

Hi,

you can try a pageblocktable to generate the rows and a repeat inside to generate the columns like this:

<apex:pageBlockTable value="{!lstLinhas}" var="linha" styleClass="center-text"> 
					<apex:repeat value="{!linha.lstDetails}" var="detalhe">
						<apex:column styleClass="center-text">
							<!-- Your cell goes here! -->
						</apex:column>
					</apex:repeat>
					<!--Define the headers here and hide the empty cells that are created -->
       				<apex:repeat var="header" value="{!lstCanais}">
           				<apex:column styleClass="empty-column-content" >
           					<apex:facet name="header" >
								{!header.Name}
								<br />
								Limite canal: {!header.Limite__c}
							</apex:facet>
           				</apex:column>
      	 			</apex:repeat>
				</apex:pageBlockTable>
where lstLinhas from the table value is a list of a wrapper class that contains the list to feed the repeat. Notice that you need a second repeat to generate the facets with a costum css:
 
.empty-column-content{
        	display: none;
        	text-align:center;
    	}
    	
    	.center-text{
			text-align:center;
			/*height:50px;*/
		}



I hope it helps =) 
ab84ab84
Thanks for the assistance, I tried this but receive the error:

Error: The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.

This doesn't seem to be connected to the name of the visualforce page.
TeksajoTeksajo

I have the exact same code and it works. Give a look at the link below:

http://salesforce.stackexchange.com/questions/51700/error-when-creating-page-with-customobject-as-a-standardcontroller-with-tooling

If this doesn't work, give some more details about the error. 

ab84ab84
The error I'm getting now is:

Error: Unknown property 'lstLinhas' referenced in testmatrix

Do I need to define lstLinhas anywhere?  You mentioned this is a wrapper class, is this in SF by default?
TeksajoTeksajo

No... that is a list of objects of your wrapper class. You have to declare a class inside your controller or outside and then insert them in that list. So:

- lstLinhas defines the list used to make rows for your matrix and each row is a object of your wrapper class;
- each wrapper class object contains a list of anything you want and it's used to feed the repeat and for each position of this list you get another column. If you just want to output a String use a list of string, otherwise use a list of sobjects or a list of other wrapper class objects; 
- look that the bigger the lists the bigger the matrix. 

Here is some information about the wrapper classes:

https://developer.salesforce.com/page/Wrapper_Class

Salesforce P1Salesforce P1
Hi,
I have a similar requirement. Have 2 lists.
Need to display a 2 d matrix.
 
 A 1A2
Pr1True(Checkbox)False(Checkbox)
Pr2True(Checkbox)True(Checkbox)