How do I make it so that when I click on the second level of the drill-down, it displays the data in the table below?
It works like this, I have a drilldown that displays the months of the year. When I click on the month column, it shows the days, and I want that when I click on the day column, it shows the data of the orders clicked on that day.

<?php
namespace App\Dashboard\TCU;
use Database\AutoMaker;
use \koolreport\dashboard\widgets\drilldown\DrillDown;
use \koolreport\dashboard\widgets\drilldown\Level;
use \koolreport\dashboard\widgets\KWidget;
class DrillDownDemo extends DrillDown
{
use \koolreport\dashboard\TWidgetState;
protected function onInit()
{
$this->settings([
"global" => [
"_token" => $this->app()->csrf()->token(),
],
"title" => "Pedidos Criado por Mês",
"icon" => "fa-solid fa-chart-simple",
"type" => "primary",
"updateOn" => "5min",
"cache" => "5min",
"updateOnNextLevel" => true
]);
}
protected function actionRowSelect($request, $response)
{
$params = $request->params();
if(isset($params["dia_num"])){
$this->state("dia",$params["dia_num"]);
}
if(isset($params["mes_num"])){
$this->state("mes",$params["mes_num"]);
}
$this->sibling("PedidosDiaTable")->update();
}
protected function levels()
{
return [
Level::create()
->title("Meses")
->widget(
KWidget::create()
->use(\koolreport\widgets\google\ColumnChart::class)
->dataSource(function($params,$scope){
return AutoMaker::table("tb_pedidos ped")
->selectRaw("
extract(month from ped.data_resposta) as mes_num,
to_char(ped.data_resposta, 'TMMonth') as mes
")
->count("ped.identificacao")->alias("total")
->whereRaw("extract(year from ped.data_resposta)=2026")
->where('ped.fk_cliente',1111111)
->whereIn('ped.status',['C','P'])
->groupByRaw("mes_num, mes")
->orderBy("mes_num")
->run();
})
->columns([
"mes"=>[
"type"=>"string",
"label"=>"Mês"
],
"total"=>[
"type"=>"number",
"label"=>"Pedidos"
],
"mes_num"=>[
"type"=>"number",
"role"=>"annotation"
]
])
),
Level::create()
->title(function($params){
return "Mês ".$params["mes"];
})
->widget(
KWidget::create()
->use(\koolreport\widgets\google\ColumnChart::class)
->dataSource(function($params,$scope){
$anoAtual = date("Y");
return AutoMaker::table("tb_pedidos ped")
->selectRaw("
extract(day from ped.data_resposta) as dia_num,
'Dia ' || extract(day from ped.data_resposta) as dia
")
->count("ped.identificacao")->alias("total")
->whereRaw("extract(year from ped.data_resposta)=".$anoAtual)
->whereRaw("extract(month from ped.data_resposta)=".$params["mes_num"])
->where('ped.fk_cliente',11111111)
->whereIn('ped.status',['C','P'])
->groupByRaw("dia_num, dia")
->orderBy("dia_num")
->run();
})
->columns([
"dia"=>[
"type"=>"string",
"label"=>"Dia"
],
"total"=>[
"type"=>"number",
"label"=>"Pedidos"
],
"dia_num"=>[
"type"=>"number",
"role"=>"annotation"
]
])
)
];
}
}
<?php
namespace App\Dashboard\TCU;
use \koolreport\dashboard\widgets\Table;
use Database\AutoMaker;
use \koolreport\dashboard\fields\Text;
use \koolreport\dashboard\fields\DateTime;
class PedidosDiaTable extends Table
{
use \koolreport\dashboard\TWidgetState;
protected function onInit()
{
$this->pageSize(10)
->searchable(true)
->showSearchBox(true)
->searchAlign("left");
}
protected function dataSource()
{
$dia = $this->sibling("DrillDownDemo")->state("dia");
$mes = $this->sibling("DrillDownDemo")->state("mes");
if(!$dia || !$mes){
return [];
}
$ano = date("Y");
return AutoMaker::table("tb_pedidos ped")
->select(
"ped.identificacao",
"ped.data_resposta",
"ped.status"
)
->whereRaw("extract(year from ped.data_resposta)=".$ano)
->whereRaw("extract(month from ped.data_resposta)=".$mes)
->whereRaw("extract(day from ped.data_resposta)=".$dia)
->where('ped.fk_cliente',11111111)
->whereIn('ped.status',['C','P'])
->orderBy("ped.data_resposta","desc");
}
protected function fields()
{
return [
Text::create("identificacao")
->label("Pedido"),
DateTime::create("data_resposta")
->label("Data"),
Text::create("status")
->label("Status")
];
}
}