Gridview Ajax Custom Button Before Send Updating The Cell Value Problem

Am facing the problem of showing the loader.gif beforesend function via ajax in the yii gridview in a particular related cell value. here is my gridview.


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

'id'=>'deals-grid',

'dataProvider'=>$model->mersearch(),


'columns'=>array(

    'title',

    'description',

    array('header'=>'Valid Till','name'=>'valid','value'=>$data->valid),

   array(

                    'class'=>'DataColumn',

                    'name' => 'status',

                    'value'=>array($this,'getStatus'),

                    'filter' => $active,'sortable'=>TRUE,

                    'evaluateHtmlOptions'=>true,

            'htmlOptions'=>array('id'=>'"ordering_{$data->id}"'),

                    

                    ),

    array

            (   

            'name'=>'image',

                 'type'=>'image',

                            'value'=>array($this,'imagePath'),

                            'htmlOptions'=>array('class'=>'thumb','rel'=>'gallery'),

            ),

 array(

'class'=>'CButtonColumn',

'buttons'=>array

(


  'mail' => array

    (   

  'label'=>'mail',

  'imageUrl'=>Yii::app()->request->baseUrl.'/images/mail.png',

  'url'=>'Yii::app()->createUrl("deals/sendmail", array("id"=>$data->id))',

  'options' => array( 'ajax' => array('url'=>'js:$(this).attr("href")',

'beforeSend'=>'function(){

 $("ordering_.'$data->id'.").replaceWith("<td id=\"ordering_'.$data->id.'\"><img src=\"/images/loading.gif\"></td>");

                                                                'success'=>'function(data){$(".status").html("Mail Sent Successfully.")

                                                                    }',

                                    ),

                                                     'class'=>'mail',

                                    )),                                 


        ),

         'template'=>'{update}{delete}{mail}',

    ),

),

)); ?>

The main problem is that the $data->id in beforesend function returns blank.So i cant update that TD cell value

Maybe $data isnt initialized?

$data->id is displaying in the grid columns but not showing in ajax:beforesend function??

$data is available only to certain CButtonColumn’s buttons property options. Actually to url and visible only. You can’t use it neither in beforeSend nor in any other option except url and visible.

I was facing the same problem with label option of CButtonColumn’s buttons [size=“2”]property[/size][size=“2”], where wanted to use $data, but it is unavailable there.[/size]

[size=“2”]This is, basically, because url and visible options are treated as PHP expressions, that are being evaluated with PHP’s eval() function, while are other options are taken directly – either as string or array.[/size]