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
Satya413Satya413 

Display Time Table in VF Page

Hi,

I am trying to display a faculty time table as shown below. I want to know in what way can we link the day with the period timings. Below is my code.
 
User-added image

VF Page: 

<apex:page controller="FacultyTimeTable_con" sidebar="false">
 <apex:form >
  <br></br><br></br><br></br>
  <center>
  <b> Select Faculty </b>
  <apex:inputField value="{!tt.Faculty_Name__c}"/><br></br><br></br>
  <apex:commandButton value="Submit" action="{!submit}"/>
  </center>
  <br></br><br></br>
  <table border="1" align="center">
  <th>Periods</th>
  <th>Monday</th>
  <th>Tuesday</th>
  <th>Wednesday</th>
  <th>Thursday</th>
  <th>Friday</th>
  <th>Saturday</th>
   <apex:repeat value="{!maplist}" var="key">
   <tr>
   <td>{!key}</td>
   <apex:repeat value="{!maplist[key]}" var="value">
   <td>{!value}</td>
   </apex:repeat>
   </tr>
   </apex:repeat>
  </table>
 </apex:form>
</apex:page>

Controller: 

public class FacultyTimeTable_con {

  public time_table__c tt {get; set;}
  public list<time_table__c> ttlist {get; set;}
  public map<string,list<string>> maplist {get; set;}
  
  public FacultyTimeTable_con()
  {
    tt = new time_table__c(); 
  }
  
  public void submit()
  {
    maplist = new map<string,list<string>>();
    
    ttlist = [select name, day__c, time1__r.period__c, time2__r.period__c, 
              time1__r.name, time2__r.name, faculty_name__r.name from time_table__c 
              where faculty_name__c = :tt.faculty_name__c];
              
    for(time_table__c t : ttlist)
    {
       if(!maplist.containskey(t.time1__r.period__c))
         maplist.put(t.time1__r.period__c,new list<string>());
         maplist.get(t.time1__r.period__c).add(t.time1__r.name);
         
       if(!maplist.containskey(t.time2__r.period__c))
         maplist.put(t.time2__r.period__c,new list<string>());
         maplist.get(t.time2__r.period__c).add(t.time2__r.name);  
    }
  }
}