效果展示:
代码实现:
控制器
5,'totalCount' => $query->count(),]);
$countries = $query
->offset($pagination->offset)
->limit($pagination->limit)
->all();
return $this->render('list',[
'brr' => $countries,'pagination' => $pagination,]);
}
//即点即改
public function actionUpdates()
{
$request = Yii::$app->request;
$id = $request->get('old_id');
$name = $request->get('old_val');
$connection=Yii::$app->db;
$command = $connection->createCommand("update ecs_goods set goods_name='$name' where goods_id='$id'");
$re=$command->execute();
if($re)
{
echo 1;
}
}
//单删
public function actionDel()
{
$request = Yii::$app->request;
$id = $request->get('ids');
$connection=Yii::$app->db;
$command = $connection->createCommand("delete from ecs_goods where goods_id='$id'");
$re=$command->execute();
if($re)
{
echo 1;
}
else
{
echo 0;
}
}
//批删
public function actionAlldel()
{
$request = Yii::$app->request;
$id = $request->get('new_str');
$connection=Yii::$app->db;
$command = $connection->createCommand("delete from ecs_goods where goods_id in($id)");
$re=$command->execute();
if($re)
{
echo 1;
}
else
{
echo 0;
}
}
}
视图层
[html] view plain copy 在CODE上查看代码片派生到我的代码片
<Meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
循环数据
@H_502_20@
Box" onclick="check_qx(this);">名称
$pagination]) ?>
Box" value="全选" onclick="check_qx(this);">全选 Box" value="全不选" onclick="check_bx(this);">全不选 Box" value="反选" onclick="check_fx();">反选 删除" onclick="check_del();">