i’ve been having a problem trying to add a custom button to the CButtonColumn in my CGridView.
Adding the button works fine, but when i try to add the ‘click’ option, things start going messy.
what i have is this:
array(
'class'=>'CButtonColumn',
'template' => '{view}{update}{delete}{activate}', //include the standard buttons plus the new status button
'htmlOptions'=> array('style'=>'width:80px'),
'deleteConfirmation'=>"js:'Wilt u de account van '+$(this).parent().parent().children(':nth-child(1)').text()+' '+$(this).parent().parent().children(':nth-child(2)').text()+' verwijderen ?'",
'buttons'=>array(
'activate'=>array(
'visible'=>'$data->role=="inactive"',
'label'=>'activate',
'imageUrl'=>'images/icon/activate.png',
'options'=>array('class'=>'update'),
)
)
)
found my problem … appearently you can’t just call the function whatever you want, it has to be called ‘function(){//insert code}’
looks like a silly mistake
ok, now my second problem rises
my deleteConfirmation looks like this
'deleteConfirmation'=>"js:'Wilt u de account van '+$(this).parent().parent().children(':nth-child(1)').text()+' '+$(this).parent().parent().children(':nth-child(2)').text()+' verwijderen ?'",
now when i try to add similar code to my ‘click’ function for the activate button, there is the problem of double and single quoting
my solution was
'click'=><<<EOD
function(){
confirm("'Wilt u de account van '+$(this).parent().parent().children(':nth-child(1)').text()+' '+$(this).parent().parent().children(':nth-child(2)').text()+' activeren ?'")
}
EOD
now this doesn’t break anything anymore, but it literally displays the text, instead of interpreting .parent().parent() and so on
i know this is just a matter of getting my quotes straight, but i could really use some help
array(
'class'=>'CButtonColumn',
'template' => '{view}{update}{delete}{activate}', //include the standard buttons plus the new status button
'htmlOptions'=> array('style'=>'width:80px'),
'deleteConfirmation'=>"js:'Wilt u de account van '+$(this).parent().parent().children(':nth-child(1)').text()+' '+$(this).parent().parent().children(':nth-child(2)').text()+' verwijderen ?'",
'buttons'=>array(
'activate'=>array(
'visible'=>'$data->role=="inactive"',
'label'=>'activate',
'imageUrl'=>'images/icon/activate.png',
'options'=>array('class'=>'update'),
'click'=><<<EOD
function(){
confirm('Wilt u de account van '+$(this).parent().parent().children(':nth-child(1)').text()+' '+$(this).parent().parent().children(':nth-child(2)').text()+' activeren ?')
}
EOD
in case anyone else would encounter the same problem