V
V
VicTHOR2021-03-15 10:43:04
Yii
VicTHOR, 2021-03-15 10:43:04

Why doesn't kartik GridView group data?

I have a table with recursive data like

id
name
some_data
parent_id
parent_id refers to the id of the same table.

I use kartik GridView
It is necessary to group the data, and in the rows of models that are parents, display only 1 column and stretch.

I tried adding a column
[
    'attribute' => 'ParentID',
    'group' => true,
    'groupedRow' => true,
    'value' => function ($model) {
        return $model->parent->Description . ' (' . $model->ParentID . ')';
    },
    'groupOddCssClass' => 'kv-grouped-row',
    'groupEvenCssClass' => 'kv-grouped-row',
],
However, the data is not grouped, the same header is shown several times... I put the id in the header, they are the same.
Since the hash is stored in ParentID, I tried to specify it - the result is absolutely the same. Why data is not grouped and how to do it? UPD: If you sort the data by ParentID, it is grouped normally by ParentID, but how to make subdirectories somehow? When ParentID can refer to a non-null ID. Subtitles. 'attribute' => 'parent.Code',


Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question