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
kostya15kostya15 

How to use rowspan attribute of dataTable column?

Hi All,

 

I'm using dataTable component to visualize statistic data. Simple example is here:

 

Table1

 

I would like to merge in column "Land" such cells like 'DACH' or 'UK' with the empty cells below.

 

I've tried to set rowspan attribute of "Land" column:

 

 

<apex:dataTable value="{!Acc2}" var="acc" id="theTable" rowClasses="odd,odd,even,even" border="1" cellpadding="5" cellspacing="1" styleClass="tableClass" bgcolor="lightyellow" >
<apex:column rowspan="2">  
   <apex:facet name="header">Land</apex:facet>
   <I><apex:outputText value="{!acc.Land}"/> </I>
</apex:column> 

and got the following result where empty cells shift right:

 

Table2

 

 

As dataset for table the list of custom classes is provided.

 

Do you have any ideas how it can be implemented?

 

Thank you in advance,

  Kostja

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

I think the problem here is that you are always rendering a land column with a rowspan of 2 for each element in the list.  Assuming you have four elements in the list, you'll end up with land aspect trying to span 8 rows in a four row table.

 

Try changing to the following:

 

 

<apex:dataTable value="{!Acc2}" var="acc" id="theTable" rowClasses="odd,odd,even,even" border="1" cellpadding="5" cellspacing="1" styleClass="tableClass" bgcolor="lightyellow" >
<apex:column rowspan="2" rendered="{!NOT(ISBLANK(acc.Land))}">  
   <apex:facet name="header">Land</apex:facet>
   <I><apex:outputText value="{!acc.Land}"/> </I>
</apex:column> 

 

I think this should work, but I'm not 100% sure as I've not conditionally rendered cells in this way before.

 

 

 

All Answers

bob_buzzardbob_buzzard

I think the problem here is that you are always rendering a land column with a rowspan of 2 for each element in the list.  Assuming you have four elements in the list, you'll end up with land aspect trying to span 8 rows in a four row table.

 

Try changing to the following:

 

 

<apex:dataTable value="{!Acc2}" var="acc" id="theTable" rowClasses="odd,odd,even,even" border="1" cellpadding="5" cellspacing="1" styleClass="tableClass" bgcolor="lightyellow" >
<apex:column rowspan="2" rendered="{!NOT(ISBLANK(acc.Land))}">  
   <apex:facet name="header">Land</apex:facet>
   <I><apex:outputText value="{!acc.Land}"/> </I>
</apex:column> 

 

I think this should work, but I'm not 100% sure as I've not conditionally rendered cells in this way before.

 

 

 

This was selected as the best answer
kostya15kostya15

Hi,

 

Thank you very much. Now it works.

 

I don't use 

 

rendered="{!NOT(ISBLANK(acc.Land))}"

 

,because then column title is also not shown, I write 'x' to empty cells of land variable and use:

 

 

rendered="{!acc.Land!='x'}"

 

Best regards,

  Kostja

 

 

 

stunaitestunaite

Hi, I'm facing the same problem about column title in a PageBlockTable. When I rowspan the first column the column title is not appearing: 

 

<apex:column rowspan="15" rendered="{!p.check1__c == 'x'}">
   <apex:facet name="header">Product</apex:facet>
   <apex:outputfield value="{!p.name}"/>
</apex:column>

 

Can y help ASAP? Thanks in Advance

 

Joao