KoolReport's Forum

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

Drilldown Table usage #2192

Open Niall McGuirk opened this topic on on Jul 8, 2021 - 4 comments

Niall McGuirk commented on Jul 8, 2021

I'm trying to create a Drilldown table, which leads to another Table once clicking on the Year row.

I've changed the drilldown Sales By Time example to use a table with a search option. However, I can't get the Year Row to be clickable to the next Table.

Here is the Drilldown Section code in MyReport.view.php:

DrillDown::create(array(
        "name"=>"DelvRef",
        "title"=>"Summary of Councils",
        "levels"=>array(
            array(
                "title"=>"All Years",
                "content"=>function($params,$scope)
                {
                    Table::create(array(
							"dataStore"=>$this->dataStore("result"),
							//"removeDuplicate"=>array("customerName","orderNumber"),
							"cssClass"=>array(
								"table"=>"table table-bordered"
							),
							"columns"=>array(
								"DelvRef"=>array(
									"label"=>"DelvRef",
								),
								"SourceType"=>array(
									"label"=>"Source Type",
									"type"=>"string",
								),
								"Invoice_Value"=>array(
									"label"=>"Invoice Value",
									"prefix"=>"£",
								),
								"ClaimTotal"=>array(
									"label"=>"Claim Total",
									"prefix"=>"£",
								),
								"PaymentYear"=>array(
									"label"=>"Year",
									"type"=>"string",
								)

							),
							"clientEvents"=>array(
                            "itemSelect"=>"function(params){
                                DelvRef.next({year:params.selectedRow[04]});
                            }",
                        )
						));
                }
            ),
			
			
            array(
                "title"=>function($params,$scope)
                {
                    return "Year ".$params["year"];
                },
                "content"=>function($params,$scope)
                {
                            Table::create(array(
								"dataStore"=>$this->dataStore("councilsResults"),
								//"removeDuplicate"=>array("customerName","orderNumber"),
								"cssClass"=>array(
									"table"=>"table table-bordered"
								),
								"columns"=>array(
									"FY"=>array(
										"label"=>"FinancialYear",
									),
									"KnownAs"=>array(
										"label"=>"Name",
										"type"=>"string",
									),
									"DelvRef"=>array(
										"label"=>"DelvRef"
									),
									"SourceType"=>array(
										"label"=>"SourceType",
										"prefix"=>"",
									),
									"RK"=>array(
										"label"=>"Rank",
													),
									"TotalInvoiceAmount"=>array(
										"label"=>"Invoice Value",
										"prefix"=>"£",
													),
									"Claim_Total"=>array(
										"label"=>"Claim Value",
										"prefix"=>"£",
									)

								)
							)); //end of Table:Create
                }        
            )
        ),
        "themeBase"=>"bs4",
    ));
Sebastian Morales commented on Jul 9, 2021

Pls use the following "itemSelect" function with some console.log

                    "clientEvents"=>array(
                        "itemSelect"=>"function(params){
                                console.log('Table itemSelect event', params);         
                                console.log('year = ', params.selectedRow[04]);       
                                DelvRef.next({year:params.selectedRow[04]});
                        }",
                    )

Then open the dev tool in your browser (F12) and refresh it, click a row and see if there's any "Table itemSelect event" output together with params value in dev tool's console. You can also see if there's any javascript error (red messages) in dev tool's console and get the idea where things went wrong.

P.S: I just notice that it should be params.selectedRow[4] (if it exists) instead of params.selectedRow[04].

Niall McGuirk commented on Jul 9, 2021

I placed your code, and opened the dev tools on console. When I click on the table row, or the specific item in the columns, nothing appears on the console. What part on the row should I be clicking? It seems to be just plaintext for each row.

This is where I placed the Code, jsut in case it's not right:

                       "columns"=>array(
                            "year"=>array(
                                "type"=>"string",
                                "label"=>"Year",
                            ),
                            "sale_amount"=>array(
                                "label"=>"Sale Amount",
                                "prefix"=>"$",
                            )
                        ),
						"clientEvents"=>array(
                        "itemSelect"=>"function(params){
                                console.log('Table itemSelect event', params);         
                                console.log('year = ', params.selectedRow[4]);       
                                DelvRef.next({year:params.selectedRow[4]});
                                }",
Sebastian Morales commented on Jul 12, 2021

Pls check Table widget's client events at this link:

https://www.koolreport.com/docs/koolphp/table/#table-settings-client-events

I think we should use "rowClick" here instead of "itemSelect". Pls try it and check for console.log message and error if there is. Tks,

Niall McGuirk commented on Jul 13, 2021

I've put in the Rowclick code, from your link.

This is the console when clicking the Year column in the table.

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
help needed

DrillDown