kartik-v / yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
http://demos.krajee.com/dynagrid
Other
74 stars 66 forks source link

How to extend the class kartik\dynagrid\DynaGrid? #230

Closed mepihindeveloper closed 4 years ago

mepihindeveloper commented 4 years ago

Prerequisites

Steps to reproduce the issue

  1. Create child class in modules/appWidgets/widgets/grid
  2. use in view DynaGridViewAdvanced widgwt
  3. see error

Environment

Browsers

Operating System

Libraries

Isolating the problem

Text

Installed the DynaGrid plugin and ran into the problem of expanding it. I created my own class DynaGridViewAdvanced, which is located on the path modules/appWidgets/widgets/grid and has namespace app\modules\appWidgets\widgets\grid.

The class code is as follows:

<?php
declare(strict_types=1);

namespace app\modules\appWidgets\widgets\grid;

use kartik\dynagrid\DynaGrid;
use Yii;
use yii\helpers\Url;

class DynaGridViewAdvanced extends DynaGrid {
    /**
     * @var bool активность функции перехода на просмотр при двойном клике
     */
    public $transitionToView = false;

    public function init() {
        parent::init(); // TODO: Change the autogenerated stub

        if ($this->transitionToView && empty($this->rowOptions)) {
            $this->rowOptions = function($model, $key, $index, $grid) {
                $viewLink = Url::toRoute(['/' . Yii::$app->controller->id . '/view']);

                return ['ondblclick' => 'location.href="' . $viewLink . '?id="+(this.dataset.key);'];
            };
        }
    }

    public function run() {
        parent::run(); // TODO: Change the autogenerated stub
    }
}

Actually, the question is why the error is thrown out and how to fix it?

View not Found – yii\base\ViewNotFoundException

The view file does not exist: /var/www/urs/modules/appWidgets/widgets/grid/views/config.php

In DynaGrid itself there is a property _module, which stores in itself kartik\dynagrid\Module, in which there is a property configView. configView is used only in DynaGrid itself:

$dynagrid = $this->render(
    $this->_module->configView,
    [...]
)

As far as I understand the error, he is trying to find this configuration view file exactly with namespace.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.