KoolReport's Forum

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

Getting JSON Undefined error and manageTable and listScreen are not found in Phpstorm (Yii2 Framework) #3277

Closed Nick Perkins opened this topic on on Apr 3 - 6 comments

Nick Perkins commented on Apr 3

I have setup a controller which successfully when going to http://localhost:8000/new-reports will show the UI but it gives an error. See below screenshot. Why am I getting this error and how can resolve it? I see in Phpstorm that the two methods in my UserTable.php file , manageTable and listScreen are giving a warning that they are not found, but I am extending my class with the Resource class from the Dashboard. The demo shows the same usage.

Files setup

[folder]models - User.php (my objects in the database)

[folder]controllers - NewReportsController (calls App.php and loads it)

[folder]reports - App.php (start of dashboard code) - UserBoard.php (board showing UserTable.php) - UserTable.php (showing table)

Trying to model my dashboard from this example

What am I missing to get this to work? I even tried setting up a DatabaseService.php to direct connect (like the example AutoAdminMaker class) instead of using my classes as I always have on this project. Any help would be greatly appreciated from those working with Yii2 or even the owners of this product giving helpful advice would be wonderful. Thanks in advance.

KoolReport commented on Apr 4

Hi Nick, I have seen that you use the admin panel feature. I see that the UserTable is derived from Resource, not from a normal Table. So in this case, the UserTable acts as a Dashboard object. The UserTable should be added to the sidebar() function in App.php

protected function sidebar()
{
        return [
            "Users"=>UserTable::create()
        ];
}

The Resource from admin panel is very much different from normal Table. While Table is just a widget that you can feed in any data to be shown, the Resource allows to fully manage a datatable in database, allow CRUD. Resource uses Table to display data.

Here is the documentation both of them:

  1. Table widget
  2. Resources of Admin Panel

Let me know if you need further assistance.

Nick Perkins commented on Apr 4

I will try this.

KoolReport commented on Apr 4

Does it work? Karl told me to support you until you get this done. Please let me know.

Nick Perkins commented on Apr 4

My issue now is connecting to the database. I believe what you suggested will work, but I can not access the database. The application in Yii2 I am working on has two docker containers for the database and web app. We usually use ActiveRecord to get data via $query = User::find().

Is there another way I can use Resource and get data with ActiveRecord instead of making a connection to the database using a subclass of MySQL?

KoolReport commented on Apr 4

There are two ways:

  1. Provide the connection information for Dashboard Framework as well. Please look at create datasource example. This is the simplest way and the best way to make Resource work with database.
  2. You could use ActiveRecord but you need to overwrite all the CRUD function of Resource, which I think is troublesome. Here is the information

Please let us know if you need further information.

Nick Perkins commented on Apr 16

I got this resolved. it was an issue with my connection to the database.

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
help needed

Dashboard