gpt4 book ai didi

gridview - 如何将类添加到 GridView 中的 标签

转载 作者:行者123 更新时间:2023-12-03 12:24:21 24 4
gpt4 key购买 nike

我需要向 GridView 的 td 添加类。
我找到了 renderTagAttributes() ,但我找不到如何使用它的示例。
你能给我解释一下这个功能还是给我提供其他选择?

我的网格 View :

 <?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'name',
'price',
'quantity',
'created_at',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}',
]
],
]); ?>

提前致谢

最佳答案

例如

[
'attribute' => 'name',
'contentOptions' => ['class' => 'text-center'],
'headerOptions' => ['class' => 'text-center']
],

contentOptions - 对于 td 单元格,headerOptions - 对于 th 单元格

引用: Yii2 Docs | Column classes in GridView

关于gridview - 如何将类添加到 GridView 中的 <td> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29540715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com