How to display summaries from multiple tables in a single gridview

Hi team,

I am stuck and need your help.

I have 4 tables that capture various expenses namely;

  • personnel

  • consultancy

  • travel

  • supplies

All tables have columns restricted(hold amount of restricted funding for each row item), unrestricted(hold amount of unrestricted funding for each row item) and total(hold sum of restricted and restricted for each row item).

My challenge is to display report summaries from each table in one gridview with four columns item, restricted, unrestricted and total. My grid view should display as shown in the below example;

Item Unrestricted Restricted Total

personnel 780,000 560,000 1,340,000

consultancy 300,000 250,000 550,000

travel 100,000 150,000 250,000

supplies 350,000 200,000 550,000

Please give me ideas on how I can fetch the data summaries from the four tables and have them displayed as four rows in one grid view.

Sorry I was unable to put my sample data in a table.


Do you have to use GridView?

If the number of rows is fixed to 4 as shown above, you can just write a table without using GridView.

Softark I am using kartik GridView for the purpose of exporting the data to generate reports

I see.

How about using ArrayDataProvider instead of ActiveDataProvider for the grid?