Category archive

yii2

Explore every article in yii2, with preserved WordPress-friendly URLs.

4 articles

PHP

How to show or hide yii2 gridview action button conditionally

In Yii2 Gridview normally to display the action button we have the following chunk of code $columns = [ [‘class’ => ‘yii\grid\SerialColumn’], ‘name’, ‘description:ntext’, ‘status’, [ ‘class’ => ‘yii\grid\ActionColumn’, ] ]; The output you see as below: Now you have a scenario, to show the edit button only when the “Zon

Jun 4, 2020

Read article

CMS

Yii2 how to set custom value for checkbox in gridview widget

In Yii2, while you use gridview widget to display your table data, for performing any operation on the record by selecting the checkbox, gridview assign the value of the first column retrieved from your the result set. But you need to set some different value to the checkbox, so to do that you can use […]

Aug 4, 2019

Read article

CMS

How to wrap data column in Gridview widget in yii or yii2 framework

The column which you want to wrap should be added the property called “contentOptions” where you can apply the css property to suits your needs and requirements as below. [ ‘attribute’ => ‘column name’, ‘format’ => ‘html’, ‘noWrap’ => false, ‘mergeHeader’=>true, ‘contentOptions’ => [‘style’ => ‘width: 50%; overflow: sc

Nov 20, 2017

Read article

MVC

How to get raw sql query in yii or yii2 framework

If you have used the query builder in yii 2.0.8 framework then to get the raw sql generated use the below statement. $query->andFilterWhere([‘like’, ‘username’, $this->username]) ->andFilterWhere([‘like’, ’email_id’, $this->email]) ->andFilterWhere([‘registration_date’ => $this->register_date]); // This is echo the raw

Nov 15, 2017

Read article