D
D
di2020-06-18 15:52:55
Yii
di, 2020-06-18 15:52:55

Is it possible to hide column using js in yii2 gridview?

I want to hide/show a column in a gridview without reloading the page. Found a variant here but it doesn't work
https://overcoder.net/q/804136/%D0%BC%D0%BE%D0%B6%...
This is how I tried to hide it.

[
         'class' => 'yii\grid\CheckboxColumn',
         'header' => Listing::listingLabel(Listing::ACTIONS),
         'options' => [ 'id' => 'listing-actions', 'style' => 'display:none'],
         'name' => 'actions[]'
]


There is another option to drag the Data Tables plugin - https://stackoverflow.com/questions/46968615/yii2-...
But I really don’t want to be smeared with a ton of plugins for the sake of a trifling matter, it would seem.
Is there any easy and simple way to achieve the desired effect.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-06-18
@Delgus

'headerOptions' => ['class' => 'hidden-xs'],
'filterOptions' => ['class' => 'hidden-xs'],
'contentOptions' => ['class' => 'hidden-xs'],
//'footerOptions' => ['class' => 'hidden-xs'],

Next, add a JS handler to the class. In this case, using bootstrap 4 will hide the column on small versions of the screen.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question