Using search with TbGridView

482 views
Skip to first unread message

nworl...@gmail.com

unread,
Feb 8, 2013, 11:14:08 PM2/8/13
to yii-bo...@googlegroups.com
Hi,

In a normal CGridView, if I have the following:

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $.fn.yiiGridView.update('rabbitshow-grid', {
        data: $(this).serialize()
    });
    return false;
});
");

....

<?php $this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'rabbitshow-grid',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'columns'=>array(
        'show_id',
        'show_name',
        'show_date',
        'judge',
        'judge_id',
        'member_price',
                array(
                    'name'=>'status_id',
                    'header'=>'Status',
                    'filter'=>array('0'=>'Pending','1'=>'Open','2'=>'Closed','3'=>'Result'),
                    'value'=>'($data->getStatusText())'
                ),
        array(
            'class'=>'CButtonColumn',
        ),
    ),
)); ?>

Then the Status area in the search is also a drop down box.

However using TbGridView and the following:

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $.fn.yiiGridView.update('rabbitshow-grid', {
        data: $(this).serialize()
    });
    return false;
});
");
......
<?php $this->widget('ext.bootstrap.widgets.TbGridView', array(
    'id'=>'rabbitshow-grid',
    'type'=>'striped bordered condensed',
    'dataProvider'=>$model->search(),
    'filter'=>$model,
    'template'=>"{items}",
    'columns'=>array(
        array('name'=>'show_name', 'header'=>'Show'),
        array('name'=>'show_date', 'header'=>'Date'),
        array('name'=>'judge', 'header'=>'Judge'),
        array('name'=>'StatusText', 'header'=>'Status'),
        array(
            //'class'=>'bootstrap.widgets.TbButtonColumn',
            'class'=>'CButtonColumn',
            'htmlOptions'=>array('style'=>'width: 60px'),
        ),
    ),
)); ?>


I get 'unknown status ()' showing in the search area.

What am I doing wrong?

Note: I know I am using CButtonColumn instead of TbButtonColumn (mainly cause I don't get icons if I don't but that is a different problem), but I don't think that would cause the issue.


Regards,

Neil
Reply all
Reply to author
Forward
0 new messages