Using CRUD generated GridView . In my case, there are a lot of columns in the table in the database, so that the page does not drag over the width, I have prescribed adaptive styles for the tables.

 <div class="table-responsive"> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-responsive'], 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'col_1', 'col_2', 'col_3', ... 'col_30', 'col_31', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> </div> 

In the end, a little awkward turns out to work scrolling left to right.

Therefore, I wanted to ask if there is a possibility to select the required fields, and form a table using a group of checkboxes, for example

  • it's not very clear what you mean, write an example of what you want to receive. - fens
  • @fens For example, before the GridView table, show a list of all fields (columns) and next to it there is a checkbox for everyone to choose from. The user could select the fields (columns) he needs and click the button let's say сформировать таблицу . And Gridview generate a table with columns that the user has selected. I hope I could explain - Xfirab
  • So what's stopping you from doing this is a set of fields that need to be shown in a regular array, make a form up to a GridView with a list of all the columns, and checkboxes for them, and send it with a form, in the end, on the server side, you will receive an array with columns that you later pass to GridView . - fens
  • @fens is understandable in principle, but there may already be a ready-made solution for such tasks - Xfirab
  • one
    @Xfirab saw one such grid, you can get an idea from there: github.com/bupy7/yii2-grid - Blacknife

0