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

how to use datatable within another datatable

Hi all,
I need some help in Visual Force datatable. Is it possible to define a datatable within another datatable. I have 4 custom objects. Projects,Propsals,Workorder and Tasks.
Project will have more than 1 proposal, Proposal will have more than 1 Workorder, Workorder will have more than 1 tasks.
I wanted to display all the above 4 details in the below format using PDF.
Project Name and details.
Proposal details associated to the project.
Workorder details associated to the Proposal.
Task details associated to the Workorder
Can anyone give some sample code of using datatable within another datatable.
Thanks in advance.
Write a apex class as per u r requirements.  By taking the list object of the apex class as var to the data table and keeping inner tables which will be var tot he data memebers (Task list etc.,) u can achieve this.
I used similar kind of solution for one of my task.  see the below class
Public Class depositChecks{
    public List<String> lstDepositAmount1;
    public List<String> lstDepositAmount2;
    public List<String> lstDepositAmount3;
    public String TotalAmount;
    public String DepositTotal;
    public String TotalDepositedItems;
    public String ticketDate;
    public integer pageBreak = 1;
    public List<CC_Payment__c> lstPayments;
by writing gets and sets for the above u can merge them to the visual force page.  But this class should not be the controller for the visualforce page.  In the controller class I consturcted List object of depositChecks, and assigned it to the outer data table.  Inner data tables are pointing to the lists inside the depositchecks.
I hope this will help u.

Hi rao,

Thanks for ur reply.

But I have to generate a report like below. For example If I have a proposal, for this proposal more than 1 workorder is defined, for 1 workorder more than 1 area is defined and for those areas many tasks are associated.

Proposal Information:


Created Date:

Workorder Name: Workorder1

Area Name : Area1

Task Name:     Quantity     Savings

Task1                  10             80

Task2                  20             15

Workorder Name: Workorder2

Area Name : Area2

Task Name:     Quantity     Savings

Task3                 10             80

Task4                  20             15

I have defined 2 datatables. Ist datatable will have workorder and area details and 2nd datatable will have area and task details.

I wanted to know how to combine these 2 datatables in such a way that outter loop will be 1st datatable and inner loop will be datatable2.

Message Edited by Shalini on 10-07-2008 07:04 AM