Admin Grid View Delete And View Delete


In _view I put a pagination 10 and add a delete link in each row but the problem is in the next page if i click the delete in my _view the one that i want to delete is not and some in the row is deleted but if im in the page1 i can delete the row that i want…

<div class="view">


	<b><?php echo CHtml::encode($data->getAttributeLabel('dept')); ?>:</b>

	<?php echo CHtml::encode($data->dept); ?>

	<br />


	  echo CHtml::link(CHtml::encode('Delete'), array('Delete', 'id'=>$data->id)  ,



    'submit'=>array('delete', 'id'=>$data->id),

    'class' => 'delete','confirm'=>'Are you sure to delete?'





Dear Friend

You are absolutely correct.

This happens because htmlOption submit registers a script on the clent side.

When CListView loads pages by AJAX ,the script is not registered.

To circumvent this, we have to register a script in index.php.

views/section/index.php (Section is my model)


<?php $this->widget('zii.widgets.CListView', array(



)); ?>




$("body").on("click",".items .link",function(){

	var sid=$(this).attr("id");

	if(confirm("Do you want delete this item?"))





.item is the class name for CListView.

.link is the pseudoclass assigned by me for individual links.

In _view.php I have added the link.


<div class="view">

	<b><?php echo CHtml::encode($data->getAttributeLabel('id')); ?>:</b>

	<?php echo CHtml::link(CHtml::encode($data->id), array('view', 'id'=>$data->id)); ?>

	<br />

	<b><?php echo CHtml::encode($data->getAttributeLabel('name')); ?>:</b>

	<?php echo CHtml::encode($data->name); ?>

	<br />



    echo CHtml::link(CHtml::encode('Delete this Item'),"#",array('id'=>$data->id,'class'=>'link'));