0

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.

See the full error page:

enter image description here

Community
  • 1
  • 1
mepihindeveloper
  • 195
  • 1
  • 14
  • what line does it throw this error on add the full stack trace – Muhammad Omer Aslam Apr 17 '20 at 12:42
  • @MuhammadOmerAslam added image, but with bad quality. Error in: `/vendor/yiisoft/yii2/base/View.php` line 233. Its try to find `view/config.php` in my own directory, but not in source.... – mepihindeveloper Apr 17 '20 at 12:50
  • The `Widget::render()` method uses the widget class as view context and default implementation of its `getViewPath()` points to `views` subfolder where your class is. You should probably override the `getViewPath()` method and use `ReflectionClass::getParentClass()` to point to proper location. See the `getViewPath()` implementation here https://github.com/yiisoft/yii2/blob/master/framework/base/Widget.php#L256 – Michal Hynčica Apr 17 '20 at 14:04

0 Answers0