花椒
GridView::widget([
// ......
'options' => ['class' => 'grid-view','style'=>'overflow:auto', 'id' => 'grid'],
// ......
'columns' => [
// ......
[
'class' => 'yii\grid\CheckboxColumn',
'name' => 'id',
],
// ......
],
]);
$this->registerJs('
$(".gridview").on("click", function () {
var keys = $("#grid").yiiGridView("getSelectedRows");
console.log(keys);
});
');- 花椒 2017-06-12 已签到连续签到1天,获得了5个金钱
- 花椒 赞了回答
在controller的beforeAction里面,重新设置db组件呗。
\Yii::$app->set('db', [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=' . $dbHost . ';dbname=' . $dbName, 'username' => $dbUser, 'password' => $dbPassword, 'charset' => 'utf8', 'emulatePrepare' => true, 'tablePrefix' => 'xx_', ]);
其中的$dbHost, $dbName, $dbUser, $dbPassword都是可以动态指定的。
- 花椒 2017-02-06 已签到连续签到1天,获得了5个金钱
- 花椒 2017-02-03 已签到连续签到1天,获得了5个金钱
- 花椒 2016-09-30 已签到连续签到1天,获得了5个金钱
- 花椒 2016-09-19 已签到连续签到1天,获得了5个金钱
- 花椒 2016-09-07 已签到连续签到2天,获得了10个金钱
- 花椒 2016-09-06 已签到连续签到1天,获得了5个金钱
- 花椒 2016-08-29 已签到连续签到1天,获得了5个金钱