PHP code example of qingbing / pf-widgets-table-view
1. Go to this page and download the library: Download qingbing/pf-widgets-table-view library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
qingbing / pf-widgets-table-view example snippets
$this->widget("\Widgets\TableView", [
'header' => [
'id' => [
'label' => '学生ID',
'width' => '20%',
'class' => 'text-left',
'default' => '...',
],
'name' => [
'label' => '姓名',
'class' => 'text-left',
'default' => '...',
],
'sex' => [
'label' => '性别',
'class' => 'text-center',
'default' => '密',
],
'score' => [
'label' => '分数',
'class' => 'text-center',
'default' => '-',
],
'level' => [
'label' => '分数等级',
'class' => 'text-center',
'default' => '-',
],
],
'data' => [
],
]);
$pager = new stdClass();
$pager->pageSize = 5;
$pager->totalCount = 1001;
$this->widget("\Widgets\TableView", [
'header' => [
'id' => [
'label' => '学生ID',
'width' => '20%',
'class' => 'text-left',
'default' => '...',
],
'name' => [
'label' => '姓名',
'class' => 'text-left',
'default' => '...',
],
'sex' => [
'label' => '性别',
'class' => 'text-center',
'default' => '密',
],
'score' => [
'label' => '分数',
'class' => 'text-center',
'default' => '-',
],
'level' => [
'label' => '分数等级',
'class' => 'text-center',
'default' => '-',
],
],
'data' => [
["id" => 1, 'username' => 'charles', 'sex' => 'nan', 'score' => 60],
["id" => 2, 'username' => 'phpcroner', 'sex' => 'nan', 'score' => 60],
["id" => 3, 'username' => 'qingbing', 'scroe' => 60],
["id" => 3,],
],
'dataProcessing' => function ($re) {
if (!isset($re['score'])) {
$level = "未参考";
} elseif ($re['score'] < 60) {
$level = "不合格";
} elseif ($re['score'] < 80) {
$level = "合格";
} else {
$level = "优秀";
}
return [
'level' => $level,
];
},
'pager' => $pager,
]);