Try this , i hope this will help you, instead of this kartikgridCheckboxColumn
use this yiigridCheckboxColumn
Step 1:
create a button for multiple delete in index.php
<input type="button" class="btn btn-info" value="Multiple Delete" id="MyButton" >
Step 2:
In your index.php(same page) use this javascript
<?php
$this->registerJs('
$(document).ready(function(){
$('#MyButton').click(function(){
var HotId = $('#w4').yiiGridView('getSelectedRows');
$.ajax({
type: 'POST',
url : 'index.php?r=hotel/multiple-delete',
data : {row_id: HotId},
success : function() {
$(this).closest('tr').remove(); //or whatever html you use for displaying rows
}
});
});
});', yiiwebView::POS_READY);
?>
this jquery is used to get the value(id) of selected row
Step 3:
in controller of hotel (HotelController.php)
create a action for multiple-delete
public function actionMultipleDelete()
{
$pk = Yii::$app->request->post('row_id');
foreach ($pk as $key => $value)
{
$sql = "DELETE FROM hotel WHERE hotel_id = $value";
$query = Yii::$app->db->createCommand($sql)->execute();
}
return $this->redirect(['index']);
}
Try this surely this will help you...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…