I have a List that gets populated based on Start Date and end Date range that user has provided on UI. Say for example, if Start Date = 01/02/2017 and End Date = 15/02/2017, than List of dateWrapper will contain 15 entires as per the date range.
Now I want to create an html table where static header will be week days i.e. 1 row (one tr) with 7 columns (7 td's) (Sunday to Saturday). Than the dynamically iterating over list, table rows and columns needs to be placed as the date range.
As an output, the table should look like:
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5 7 8 9 10 11
12 13 14 15
How do we achieve this?
Approach that I tried is below: Sunday Monday Tuesday Wednesday Thursday Friday Saturday
<!-- Dynamically display table data below-->
<apex:repeat var="datewrap" value="{!dateWrapperList}">
<tr>
<td data-label="Sunday">
<apex:outputpanel rendered="{!if(datewrap.dayOfWeek = 'Sun', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
<td data-label="Monday">
<apex:outputpanel rendered="{!if(dateWrap.dayOfWeek = 'Mon', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
<td data-label="Tuesday">
<apex:outputpanel rendered="{!if(dateWrap.dayOfWeek = 'Tue', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
<td data-label="Wednesday">
<apex:outputpanel rendered="{!if(dateWrap.dayOfWeek = 'Wed', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
<td data-label="Thursday">
<apex:outputpanel rendered="{!if(dateWrap.dayOfWeek = 'Thu', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
<td data-label="Friday">
<apex:outputpanel rendered="{!if(dateWrap.dayOfWeek = 'Fri', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
<td data-label="Saturday">
<apex:outputpanel rendered="{!if(dateWrap.dayOfWeek = 'Sat', true, false)}">
<b>{!dateWrap.dateValue}</b>
</apex:outputPanel>
</td>
</tr>
</apex:repeat>
</table>
Incorrect Output:
Sun Mon Tue Wed Thu Fri Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Expected Output: Sun Mon Tue Wed Thu Fri Sat 1 2 3 4 5 7 8 9 10 11 12 13 14 15