Access to the $data variable from buttons in cgridview

gryfi picture gryfi · Apr 4, 2011 · Viewed 8.5k times · Source

Is the any way, to access model located in $data variable from CButtonColumn? Below code is not working.

array(
'class' => 'CButtonColumn',
'template' => '{test}',
    'buttons' => array(
        'test' => array(
            'label' => 'Select',
            'click' => 'js:function() { <b>alert($data->_id);</b> return false;}',
        ),
    ),
),

Answer

chris picture chris · Feb 28, 2012

It is possible to access visible attributes from jquery:

'click'=>'js:function(){alert("first element in cgridview is"+$(this).parent().parent().children(":nth-child(1)").text());}'