+ Start a Discussion

How to display multiple data tables based on field name...?

Employee name, Time card id, date of service, hours, client pay are record colummns , i wanted to display timecards based on employee name , how to achieve this, pl help me  

 custom list records display


Naval Sharma4Naval Sharma4
Hi Deepu,

Create a map in your apex code based on employee name and use that map to show data on visualforce page. I don't have any idea about your data modal but I can provide a basic idea.

Controller code 
public Map<Id, Employee> getEmployeesData(){
	Map<Id, List<Employee>> employeedata = new Map<Id, List<Employee>>();
	for(Employee__c emp = [SELECT Id, cardId__c, Name, dateOfService__c, hours__c, clientPerHours__c FROM Employee__c]){
			employeedata.put(emp.name, new Employee());
		employeedata.get(emp.Name).lstEmployee.add(new EmployeeInfo(emp.cardId__c, emp.dateOfService, emp.hours, emp.clientPerHours));
	return employeedata;

public class Employee{
    public boolean isSelected {get;set;}
    public List<EmployeeInfo> lstEmployee {get;set;}
    public Employee(){
       isSelected = false;
       lstEmployee = new List<EmployeeInfo>();
public class EmployeeInfo{
	public String timeCardId {get;set;}
	public String dateOfService {get;set;}
	public Integer hours {get;set;}
	public Integer clientPerHours {get;set;}
	public EmployeeInfo(String timeCardId, String dateOfService, Integer hours, Integer clientPerHours){
		this.timeCardId = timeCardId;
		this.dateOfService = dateOfService;
		this.hours = hours;
		this.clientPerHours = clientPerHours;

VF Page code
<apex:repeat value="{!EmployeeData}" var="emp">
				<th> <apex:inputcheckbox value="{!EmployeeData[emp].isSelected}"> {!emp} </th>
				<th> Time Card Id </th>
				<th> Date of Service </th>
				<th> Hours </th>
				<th> Client per/hour </th>
			<apex:repeat value="{!EmployeeData[emp].lstEmployee}" var="empData"/>
				<td> <apex:inputcheckbox value="{!empData.isSelected}"> </td>
				<td> {!empData.timeCardId} </td>
				<td> {!empData.dateOfService} </td>
				<td> {!empData.hours} </td>
				<td> {!empData.clientPerHours} </td>

I hope this would help you and you can modify this according to your need.

Naval Sharma4Naval Sharma4
This code is not compiled so please fix any syntax errors.