Filters Not Working Properly In Pages With Two Tbgridviews

Hey all,

Firstly to say I’m a total noob with Yii, 9 days in. So please be gentle with me ::)

I have a page which has two TbGridView grids on it.

They are both driven by one controller with different methods in their model and each has it’s own partial view.

Both tables are identical except the data that they display.

Each table has it’s own id.

My issue comes when I enter something in the filter text field at the top.

Whatever I enter into the top grid and hit enter then populates into the second grid.

It seems that the textfield has an ID or some such that I need to change.

Unfortunately I don’t know where that can be changed.

One of my partial views for reference. There are obviously two views but they are identical except the ID




$this->widget('bootstrap.widgets.TbGridView', array(

        'dataProvider' 	=> $data,

        'filter'		=> $model,

        'id' 			=> 'subject-split-grid',

        'type' 			=> 'striped bordered condensed',

        'template'		=> $data->totalItemCount > OverviewController::PAGE_SIZE ?

            '<div class="row-fluid"><div class="pull-right">'.$filterBtn.'</div><div class="pull-right" style="padding-top:5px;">{summary}</div></div>{items}<div class="row-fluid"><div class="pull-left">{pager}</div><div class="pull-right" style="margin-top: 20px;">'.$filterBtn.'</div></div>':

            '<div class="row-fluid"><div class="pull-right">{summary}</div></div>{items}<div class="row-fluid"><div class="pull-left">{pager}</div></div>',

        'htmlOptions'	=> array(

            'style'			=> 'margin-bottom: 0;'

        ),

        'columns' 		=> array(

            array(

                'name'	=> 'full_subject_name',

            ),

            array(

                'name' 				=> 'totalS',

                'htmlOptions' 		=> array('style'=>'text-align:center;'),

                'header'			=> 'No. S',

                'headerHtmlOptions' => array('style'=>'text-align:center;width:100px;'),

                'footer'			=> $model->totalSFooter.' <sup style="font-size:.55em; font-weight:normal; top:-.8em;">†</sup>',

                'footerHtmlOptions' => array('style'=>'text-align:center;font-weight:bold;font-size:1.1em;'),

                'filter'			=> false

            ),

            array(

                'name' 				=> 'totalR',

                'htmlOptions' 		=> array('style'=>'text-align:center;'),

                'header'			=> 'Total R',

                'headerHtmlOptions' => array('style'=>'text-align:center;width:100px;'),

                'footer'			=> $model->totalRFooter,

                'footerHtmlOptions' => array('style'=>'text-align:center;font-weight:bold;font-size:1.1em;'),

                'filter'			=> false

            ),

            array(

                'name' 				=> 'totalP',

                'htmlOptions' 		=> array('style'=>'text-align:center;'),

                'header'			=> 'Total P',

                'headerHtmlOptions' => array('style'=>'text-align:center;width:100px;'),

                'footer'			=> $model->totalPFooter,

                'footerHtmlOptions' => array('style'=>'text-align:center;font-weight:bold;font-size:1.1em;'),

                'filter'			=> false

            ),

            array(

                'class'					=> 'application.widgets.bootstrap.TbButtonColumnFilter',

                'header'				=> 'Actions',

                'filter'				=> CHtml::link('<i class="icon icon-remove"></i> Remove Filters', array('subject', 'clearFilters'=>1), array('class'=>'remove-filters')),

                'visible'			=> !isset($attribute),

                'buttons'			=> array(

                    'view'				=> array(

                        'type' 			=> 'primary',

                        'url'			=> '$data->subject_message_link ? "/carrot/overview/subject/id/".$data->subject_id."/msg/".urlencode($data->message)."/tab/'.$activeTab.'" : "/carrot/overview/subject/id/".$data->subject_id."/tab/'.$activeTab.'"',

                    ),

                    'update'			=> array(

                        'visible'		=> 'false',

                    ),

                    'delete'			=> array(

                        'visible'		=> 'false',

                    ),

                ),

                'headerHtmlOptions' => array('style' => 'text-align:center; width: 50px;'),

            ),

        ),

    ));



I hope this makes sense, and thanks in advance for the help.


$this->widget('bootstrap.widgets.TbGridView', array(

        ...

        'id'                    => 'subject-split-grid', // right here change this id 

        ...

));

Hi,

These ID’s are different on the two grids.


'id' 			=> 'subject-grid',


'id' 			=> 'subject-split-grid',

But thanks anyway.

Yii uses element id’s as hook for ajax call’s that does not make sense use chrome tools to double check that you have to diff id’s

Hi,

I can 100% state that the id’s are different.

I’ve been continuing to dig into this and I’ve found what I think will be the issue.

As we know both grids have a filter text field. The element being output is


<input name="SubjectOverview[full_subject_name]" type="text" value="" />

This element is the same in both cases. So I’m guessing that Yii is actually targeting the element by name and obviously jQuery will find both.

This is driven by my model.

Do you think I’m correct in what I’ve surmised so far?

I shall have a look in my model and see what is in there.

Thanks again.

I don’t think that’s the problem

Hi,

Sorry for the late reply. The forum wouldn’t let me post again on my first day.

I fixed the issue by splitting the system into two modules meaning that the name of the form fields changed.

Thanks again