的列標題「我在我的項目一個GridView。現在我想列數組中打道回府。我應該使用哪種方法???看到代碼..」在yii2,如何讓GridView控件
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model app\models\Companies */
$this->title = 'Export File';//'Create Companies';
$this->params['breadcrumbs'][] = ['label' => 'Companies', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
$allColumnsDBArray = $model->getTableSchema()->getColumnNames();
//problem is here it is giving column heading of mysql database table
?>
<div class="companies-create">
<h1><?= Html::encode($this->title) ?></h1>
<div class="form-group">
<?= Html::submitButton('Export CSV', ['class' => 'btn btn-primary','name' => 'export']) ?>
<?php echo "<br>";
foreach ($allColumnsDBArray as $colHeading) {
echo $colHeading; echo "<br>";
}?>
</div>
</div>
「但它給出了mysql數據庫中的列標題和要求是gridview列標題??」
您可以在模型中使用自定義屬性標籤'$ model-> getAttributeLabel('attribute_name');'' – Kalu