效果展示:
代码实现:
控制器
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上查看代码片派生到我的代码片
循环数据
table{
background-color: pink;
}
.dels{
border: 1px solid red;
font-family:楷体;
background-color: white;
}
.trs{
background-color: red;
}
全选
全不选
反选
商品ID
商品名称
操作
">
" onclick="del(this);" class="dels">删除
= linkPager::widget(['pagination' => $pagination]) ?>
以上所述是小编给大家介绍的Javascript中全选、全不选、反选、无刷新删除、批量删除、即点即改入库(在yii框架中操作)的代码分享,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对考高分网网站的支持!



