KoolReport's Forum

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

How to know which FlexView Panel we are? #2837

Closed GHSix opened this topic on on Sep 28, 2022 - 10 comments

GHSix commented on Sep 28, 2022

In the pseudo code:

protected function content() {
return [

Panel::create()
    ->menu([
        'Details' => MenuItem::create()->icon('fa fa-table')
            ->onClick(
                Client::showLoader().
                ( Client::widget('childA') || Client::widget('childB') )->showDetail() // ?
            )
    ])
    ->sub([
        FlexView::create('myFlexView')
            ->viewOptions([...])

How to know witch flexView I'm on to be able to call showDetail() on it?

ps. I want a one Panel to hold the FlexView widget instead of a FlexView with Panels inside as in the FlexView Dashbaord example. It is working already, but I would like to add the Details menu button now.

KoolReport commented on Sep 29, 2022

You do this:

FlexView::create("myFlexView")
    ->viewOptions([
        "viewA"=>...,
        "viewB"=>...,
    ])
    ->action("showDetail",function($request, $response){
        if($this->currentView()=="viewA") {
            return $this->sibling("childOfViewA")->actionDetail($request, $response);
        } else if (...) {

        }
    })

For the menu of panel:

            ->onClick(
                Client::showLoader().
                Client::widget('myFlexView')->action("showDetail")
            )

Hope that helps.

GHSix commented on Sep 29, 2022
[Widget] myFlexView
Message: Call undefined actionDetail() method

I also tried other things like actionShowDetail, showDetail and a bunch of other undefined methods. The fact is that I don't know what to call and don't know the most important, how to find out existing methods of a KR class.

By trying with print_r(get_class_methods($this->sibling('childOfViewA')));

Array ( 
    [0] => dataView 
    [1] => __construct 
    [2] => sibling 
    [3] => existenceRegister 
    [4] => hasSibling 
    [5] => update 
    [6] => needUpdated 
    [7] => handle 
    [8] => skeletonView 
    [9] => lazyLoadingView 
    [10] => view 
    [11] => client 
    [12] => init 
    [13] => create 
    [14] => __call 
    [15] => registerMagicMethod 
    [16] => constructServices 
    [17] => fireEvent 
    [18] => registerEvent 
    [19] => __constructTProps 
    [20] => __magicGetProps 
    [21] => __magicTProps 
    [22] => props 
    [23] => getProps 
    [24] => getProp 
    [25] => _getProps 
    [26] => _getProp 
    [27] => removeProps 
    [28] => hasProp 
    [29] => hasRun 
    [30] => app 
    [31] => dashboard 
    [32] => name 
    [33] => enabled 
    [34] => enabledWhen 
    [35] => action 
    [36] => exportedView 
    [37] => renderXLSXTable 
    [38] => renderXLSXWidget 
    [39] => exportedData 
    [40] => params 
    [41] => state 
    [42] => clearState 
    [43] => hasState 
    [44] => __constructDetailAction 
    [45] => getWidgets ) {"panels":{"myFlexView":["
KoolReport commented on Sep 29, 2022

May I know what is the class of childOfViewA, is it a chart or something. It is because not all widget has actionDetail.

GHSix commented on Sep 29, 2022

I is a

\koolreport\dashboard\widgets\d3\ColumnChart;

and I'm creating it as

ArchiveDocQtdA::create('ArchiveDocQtdA')->detailShowable(true),

I had it before as a normal widget and call

Client::widget('ArchiveDocQtdA')->showDetail()

was working ok.

KoolReport commented on Sep 29, 2022

It is my mistake, the actionDetail is there but protected.

Let try this if it works:

return $this->sibling("childOfViewA")->action("detail",$request, $response);

Let me know.

GHSix commented on Sep 29, 2022

It just shows the loading for a couple seconds and nothing more.

I can see in the inspect tool the ArchiveDocQtdAdetail panel is being loading, the content looks like a modal one, but just that. No errors, nothing.

--

ps. Maybe it's getting into too much trouble for too little of economy, like get less DOM to update?

I was planning in create only one Panel with FlexView and just the graphs inside it's views, but it's starting to looks like it's just easyer to add panels everywhere and get it done. Maybe I need to print the KISS principle and glue it to my monitor.

If you guys think it's a good ideia to optimize it in that level, maybe add some example like this would help.

KoolReport commented on Sep 29, 2022

Okay, I got it.

Let do something else, in the menu of panel, you do this:

        'Details' => MenuItem::create()->icon('fa fa-table')
            ->onClick(
                Client::showLoader().
                "
                if($('ajaxpanel#ajp' + 'childOfViewA').length>0) {
                    widgetShowDetail('childOfViewA');
                } else if ($('ajaxpanel#ajp' + 'childOfViewB').length>0) {
                    widgetShowDetail('childOfViewB');
                }
                "
            )

You do not need those action showDetail codes in FlexView.

Let me know if it works.

GHSix commented on Sep 29, 2022

It worked haha. Nice one.

GHSix commented on Sep 29, 2022

Do you know something that would be nive to have bultin in FlexView, a showNextView() and showPreviousView() methods, that would make a breeze to add a global back button now. But, I guess we would need a getParams() as well.

KoolReport commented on Sep 29, 2022

I will forward your idea to our dev.team

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