FlexView

FlexView is a widget that has power of holding multiple views and ability to switch among those views. FlexView can be used as a dynamic area where content can be changed. We may use FlexView to easily create drill-down, drill-up report or anything up to your imagination. FlexView supports state persistence so the selected view will remain when you refresh dashboard or do exporting. FlexView also provides history capability so that we can be back to previous views easily.

Properties #

Nametypedefaultdescription
viewOptionsarray[]Get/get list of views
maxHistoryint10Get/set maximum steps that user can go back in history

Methods #

Namedescription
initialView(string $name [,array $params])Set initial view for FlexView, set the name to null to show blank in first load
showView(string $name [,array $params])Change to specific view, set name to null to show blank
historyBack([int $step=1])Go back on history, the default step is 1, meaning go back to previous view

Examples #

<?php
use koolreport\dashboard\Dashboard;
class MyDashboard extends Dashboard
{
    protected function content()
    {
        return [
            //Create FlexView with name myFlexView
            //that has two view options "orders" and "customers"
            //The initial view is "customers"
            FlexView::create("myFlexView")
                ->viewOptions([
                    "customers"=>function($params) {
                        return [
                            Html::h1("All customers"),
                            CustomerTable::create(),
                        ];
                    },
                    "orders"=>function($params) {
                        return [
                            Html::h1("All orders"),
                            OrderTable::create(),
                        ];
                    },
                ])
                ->initialView("orders"),

            //Button to change to customer view
            Button::create()->text("Show customers")
                ->action("submit",function(){
                    $this->sibling("myFlexView")->showView("customers");
                }),

            //Button to change to orders view
            Button::create()->text("Show orders")
                ->action("submit",function(){
                    $this->sibling("myFlexView")->showView("orders");
                }),

            //Button to go back in history
            Button::create()->text("Back")
                ->action("submit",function(){
                    $this->sibling("myFlexView")->historyBack();
                }),
        ];
    }
}

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.