durga.m
(Durga M)
October 18, 2011, 12:33pm
1
I use a grid whose data depend on a dropdown, so for pagination requests I need the dropdowns value to be passed along. I tired using this but it doesn’t work.
<div id='CustomerList'>
<?php
$this->widget('zii.widgets.grid.CGridView',array(
'dataProvider' => $customers,
//'cssFile' => Yii::app()->baseUrl.'/css/gridview/styles.css',
'ajaxUpdate' => "CustomerList",
'ajaxUrl' => Yii::app()->createUrl('customer/list',array('something' => $partner)),
'columns' => array(
array(
'name' => 'Name',
'type' => 'raw',
'value' => '$data["customer_fullname"]'
),
array(
'name' => 'Customer ID',
'type' => 'raw',
'value' => '$data["customer_id"]'
),
array(
'name' => 'Email',
'type' => 'raw',
'value' => '$data["customer_email"]'
),
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
'updateButtonUrl'=>'Yii::app()->createUrl("/customer/edit", array("id" => $data["customer_id"]))',
'deleteButtonUrl'=>'Yii::app()->createUrl("/customer/delete", array("id" => $data["customer_id"],"name" => $data["customer_fullname"]))',
),
),
));
?>
</div>
The above is the code for the GridView, $partner is the value of the dropdown.
durga.m
(Durga M)
October 18, 2011, 3:43pm
3
I have the following view called by controller-customer and action-list
<script type="text/javascript">
function ajaxtest(id,options)
{
console.log(options);
opt = options;
var str = options.url+"&partnerId="+$("#partners").val();
//options.url = str.replace("customer%2Flist","customer%2Fgrid");
}
</script>
<?php
if(isset($msg)) echo "<h3>".$msg."</h3>";
?>
<?php
$currentPage=$customers->getPagination()->currentPage;
$this->widget('zii.widgets.grid.CGridView',array(
'dataProvider' => $customers,
//'cssFile' => Yii::app()->baseUrl.'/css/gridview/styles.css',
//'loadingCssClass' => Yii::app()->baseUrl.'/css/gridview/styles.css',
'beforeAjaxUpdate'=> 'ajaxtest',
'ajaxUrl' => array('post/list', 'page'=>3),
'columns' => array(
array(
'name' => 'Name',
'type' => 'raw',
'value' => '$data["customer_fullname"]'
),
array(
'name' => 'Customer ID',
'type' => 'raw',
'value' => '$data["customer_id"]'
),
array(
'name' => 'Email',
'type' => 'raw',
'value' => '$data["customer_email"]'
),
array(
'class'=>'CButtonColumn',
'template'=>'{update}{delete}',
'updateButtonUrl'=>'Yii::app()->createUrl("/customer/edit", array("id" => $data["customer_id"]))',
'deleteButtonUrl'=>'Yii::app()->createUrl("/customer/delete", array("id" => $data["customer_id"],"name" => $data["customer_fullname"]))',
),
),
));
?>
but the ajaxUrl assignment doesn’t work. And it defaults to value if ajaxUrl was null. Its the ajaxUrl supposed to be same as the one received by js function ajaxtest in the options.url?