KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Table::create #2034

Open Lloyd opened this topic on on Apr 17, 2021 - 4 comments

Lloyd commented on Apr 17, 2021

In my view fill I have the following code:

"grouping"=>array(

"username"=>array(
	"calculate"=>array(
        	"{sumHours}"=>array("sum","hours"),
	),
											
	"top"=>"<b>User Name {username}</b>",
	"bottom"=>"<td><b>Totals </b></td><td></td><td></td><td></td><td></td><td></td><td></td><td><b>{sumHours}</b></td>",
					
),

),

I need to also calculate the sum for 3 other columns in the report. Is there a way to do this?

Any help would be greatly appreciated

Lloyd

KoolReport commented on Apr 18, 2021

Yes you can. you can put another sum the same like {sumHours}.

	"calculate"=>array(
        	"{sumHours}"=>array("sum","hours"),
                "{sumAnything}"=>array("sum","anything"),
	),
											
	"top"=>"<b>User Name {username}</b>",
	"bottom"=>"<td><b>Totals </b></td><td></td><td></td><td></td><td></td><td></td><td><b>{sumAnything}</b></td><td><b>{sumHours}</b></td>",

Lloyd commented on Apr 18, 2021

Below is my code that I modified as per your reply.

"grouping"=>array( 
	"username"=>array(
		"calculate"=>array(
			"{sumHours}"=>array("sum","hours"),
			"{sumHoursOvertime}"=>array("sum","hours_overtime"),
																		
			"top"=>"<b>User Name {username}</b>",
			"bottom"=>"<td><b>Totals </b></td><td></td><td></td><td></td><td></td><td></td><td></td><td><b>{sumHours}</b></td><td><b>{sumHoursOvertime}</b></td>",
		),
	),
),

When I add a second line to the calculate array, the grouping stops working.

Can you please try a test, and see if this works for you. There might be a bug in your code.

Any help would be greatly appreciated.

Thanks

Lloyd

KoolReport commented on Apr 18, 2021

You have syntax error, lack of close tag for calculate array, it should be:

"grouping"=>array( 
	"username"=>array(
		"calculate"=>array(
			"{sumHours}"=>array("sum","hours"),
			"{sumHoursOvertime}"=>array("sum","hours_overtime"),
                 ), // <--- This is the one
            	"top"=>"<b>User Name {username}</b>",
		"bottom"=>"<td><b>Totals </b></td><td></td><td></td><td></td><td></td><td></td><td></td><td><b>{sumHours}</b></td><td><b>{sumHoursOvertime}</b></td>",
	),
),
Lloyd commented on Apr 18, 2021

Thank you so much for finding my error, and helping me to get this to work.

I would like to purchase the DataGrid / Datatables addon, as It has more features than the Table module.

Before purchasing, I would like to know if there is a way with Datatables to do grouping with totals for each grouping break, as with the Table module.

Also can the expand row be set to open rather than closed when the Datatable is generated, requiring the user to click the icon or the row to open and show the all the rows that make up a group.

Lloyd

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None