在我的Web应用程序中,我在索引操作视图中使用网格视图。我需要创建一个名为“book”的按钮,当点击显示一个显示相关内容的对话框时。 我尝试了这个代码,但它没有对事件做出反应。 我的index.php网格视图代码
<h1>Producer Offers</h1>
<?php
$this->widget('bootstrap.widgets.TbGridView',array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'offered_vegetable',
'offered_qty',
'unit_cost',
'unit_delivery_cost',
array(
'class'=>"bootstrap.widgets.TbButtonColumn",
'deleteConfirmation'=>"js:'Do you really want to delete record with Offer name '+$(this).parent().parent().children(':nth-child(2)').text()+'?'",
'template'=>'{view}{book}{delete}',
'buttons' =>array(
'book'=>
array(
'label'=>'book',
'click' =>"js:alert('do u want to book this offer!')"
),
),
),
),
));
?>
当页面刷新时会显示,但我想在点击按钮时对事件做出反应,任何人都会帮我解决这个问题
答案 0 :(得分:4)
您可以使用选项:
'book'=> array(
'label'=>'book',
'options' => array( // set all kind of html options in here
'onclick' =>"js:alert('do u want to book this offer!')",
'style' => 'font-weight: bold',
),
)