您的位置:首页 > 编程语言 > PHP开发

Simple colum formatting in Yii 2 GridView

2016-08-15 10:14 148 查看
A very important widget in the business apps development is the GridView control. In this post I will show how to use its hidden capabilities to format the displayed data.

<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'Title', // same as 'Title:text'
'Snippet:html', // will be HTML purified
'Description:ntext', // plaintext but new lines as <br>
'Email:email', // will be shown as mailto: link
'WebSite:url', // will be shown as hyperlink
'Picture:image', // <img src="value of Picture column" />
'Maried:boolean', // true or false
'Birthdate:date',
'Birthdate:time',
'Birthdate:datetime',
'Birthdate:timestamp',
'Size:integer',
'Cost:spellout', // number as text
'DiskSize:size', // as bytes, for example `12 kilobytes`
'Size:decimal',
'Ratio:percent',
]
);
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: