du6333137 2014-02-17 09:27
浏览 94
已采纳

在yii中为网格视图的单击事件创建警报按钮

In My web application I am using grid view in index action view. I need to create a button called "book" which when clicks shows a dialog box which displays the related content. I tried this code but its not reacting to the event. My code for index.php grid view

<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!')" 


                ),
        ),
                        ),
                ),

        )); 
?>

When the page is refreshed it is displayed but I want to react to the event when the button is clicked, Anybody help me how to resolve this issue

展开全部

  • 写回答

1条回答 默认 最新

  • doushi4956 2014-02-17 21:29
    关注

    you can use options for that:

    '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',
        ),
     )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部