## ym1.0提供了三种构建表格的方法

1. 属性赋值
~~~
$table = ViewBuilder::table();
$table->columns = [
'username' => table_column_helper('用户名', ['style' => ['min-width' => '100px']]),
'email' => table_column_helper('邮箱', ['style' => ['min-width' => '200px']]),
];
$table->query = function () {
$query = AdminUser::find()->select(['id', 'username', 'email']);
return $query;
};
return $table->render($this);
~~~
2. 链式操作
~~~
return ViewBuilder::table()
->setColumns([
'username' => table_column_helper('用户名', ['style' => ['min-width' => '100px']]),
'email' => table_column_helper('邮箱', ['style' => ['min-width' => '200px']]),
])
->setQuery(function () {
$query = AdminUser::find()->select(['id', 'username', 'email']);
return $query;
})
->render($this);
~~~
3. 配置项定义
~~~
return ViewBuilder::table([
'columns' => [
'username' => table_column_helper('用户名', ['style' => ['min-width' => '100px']]),
'email' => table_column_helper('邮箱', ['style' => ['min-width' => '200px']]),
],
'query' => function () {
$query = AdminUser::find()->select(['id', 'username', 'email']);
return $query;
},
])->render($this);
~~~