yii2 gridview mongodb

Hi,

I am using yii2 with mongodb extension.

I am trying to use GridView with the following instructions.

But when I try to do the following configuration, I always get an error undefined index.




        $query = new Query();

        // compose the query

        $query->from('products');


        $provider = new ActiveDataProvider([

            'query' => $query,

            'pagination' => [

                'pageSize' => 10,

            ],

            'sort' => [

                'defaultOrder' => [

                    '_id_' => SORT_ASC,

                ]

            ],

        ]);



I must be doing something wrong? I am just trying to get it to work and be able to sort the columns.

I did the same code with a regular MySQL db connection active record and it works fine.

If I comment the ‘id’ line, it loads fine but I can’t sort.

I looked online but didn’t see any mention of this.


It seems to only work when I create an ActiveRecord class. But using Query doesn’t work.

Thanks for any help!