Hello folks,
I have the code below. As you can see, I have a CGridView inside a CActiveForm, and there’s also an ajaxSubmitButton there. The problem is: when I do a search with the CGridView’s integrated field search, two AJAX calls are thrown: a GET for the search and a POST for the ajaxSubmitButton, leading to undesired results (the search results are shown but shortly after they are replaced by the response of the ajaxClose action called on the POST). How can I prevent the POST action to be called when the CGridView calls the search action? Thanks in advanced.
My code:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id'=>'whois-form',
'enableClientValidation'=>true,
'enableAjaxValidation'=>false,
));
?>
<div id="divGrid">
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'whois-grid',
'dataProvider' => $model->search(),
'filter' => $model,
'showTableOnEmpty' => false,
'selectableRows' => 2,
'ajaxUpdate'=>true,
'pager'=>array(
'cssFile'=>false,
),
'columns' => array(
array(
'name' => 'user',
'header'=>'Full name',
'value' => '$data->user->fullName',
),
array(
'class' => 'CDataColumn',
'name' => 'start_date',
'type'=>'html',
'header' => 'Start date',
'value' => '$this->grid->getController()->df->formatDateTime($data->start_date, "short", null)',
),
array(
'class' => 'CDataColumn',
'name' => 'last_date',
'type'=>'html',
'header' => 'Last seen',
'value' => '$this->grid->getController()->df->formatDateTime($data->last_date, "short", null)',
),
'ip',
array(
'id' => 'chbox_sessions',
'value' => '$data->id',
'class' => 'CCheckBoxColumn',
'header' => 'Delete',
),
),
));
?>
</div>
<?php
echo CHtml::ajaxSubmitButton(
'Terminate marked sessions',
array('/security/whois/online/ajaxClose'),
array(
'type' => 'post',
'update' => '#divGrid',
));
?>