CGridView lost "default" parameters when we use the input filters

in portuguese:

http://www.yiiframework.com/forum/index.php/topic/29973-cgridview-perde-filtros-padroes-depois-que-usa-o-filters/

Hello folks!

I have a component that when get a row, it filter the grid with this lines:


var vData = "id=" + pId;

jQuery.fn.yiiGridView.update(pGridId, {data: vData});



So, when i use the input in the grid`s filter, it lost mine first parameter ("id=" + pId)…

the question is: i saw in $.fn.yiiGridView that it has pageVars, but i couldn`t use…what i need to do to maintain the first filter?

theres another problem, when i use the cgridviews sort, the filter don`t work anymore…why?

can you post the code for your cgridview here

Thx bettor.

Here:




<?php

$form = $this->beginWidget('CActiveForm', array(

    'id' => 'form',

    'enableAjaxValidation' => false,

    'htmlOptions' => array('enctype' => 'multipart/form-data'),

        ));

?>

            <?php

            $this->widget('application.widgets.SearchField', array('model' => $model,

                'id' => 'ptUsuarios',

                'attribute' => 'parusua_id',

                'class' => 'Usuario',

                'labelField' => 'desc_login',

                'title' => 'Usuários',

                'columns' => array('desc_login'),

                'gridToUpdate' => 'gridUsuarioEmpresa',

                'fieldToFilter' => 'UsuarioEmpresa[parusua_id]',

            ));

            ?>


<?php $this->endWidget(); ?>


<?php echo $this->renderPartial('_gridEmpresaUsuario', array('model' => $model)); ?>



_gridEmpresaUsuario:




<?php


$this->widget('application.widgets.GridView', array(

    'id' => 'gridUsuarioEmpresa',

    'dataProvider' => $model->search(),

    'filter' => $model,

    'navegacao' => false,

    'columns' => array(

        array('name' => 'parempr_id',

            'value' => '$data->parempr->parentd->desc_razao_social',

        ),

        array(

            'name' => 'indr_padrao',

            'htmlOptions' => array(

                'style' => 'text-align: center',

            ),

            'headerHtmlOptions' => array(

                'style' => 'text-align: center',

            ),

            'filter' => array('S' => 'SIM',

                'N' => 'NÃO',

            ),

        ),

        array('class' => 'CButtonColumn',

            'template' => '{update}{delete}',

            'buttons' => array(

                'update' => array(

                    'label' => 'Editar',

                    'imageUrl' => Yii::app()->baseUrl . '/images/grid/ico_editar.png',

                    'url' => 'Yii::app()->getController()->createUrl("editar", array("id" =>$data["id"]))',

                ),

                'delete' => array(

                    'label' => 'Apagar Produto',

                    'imageUrl' => Yii::app()->baseUrl . '/images/grid/ico_excluir.png',

                    'url' => 'Yii::app()->getController()->createUrl("deletar", array("id" =>$data["id"]))',

                    'click' => 'function(){if(confirm("Deseja Realmente Excluir este Registro ?"))return true; else return false;}',

                ),

        ))

    ),

));

?>



my GridView:

http://pastebin.com/0mqppx27

So, my SearchField theres a grid in, when we select a row, theyll filter the gridUsuarioEmpresa grid!!

take a look:

searchfield clicked:

grid filtered:

bug:

when i click in searchfield`s grid, i call this one:




$.fn.updateSecondGrid = function (pId, pGridId, pLabelField) {

    if(pId.length >= 1 && pGridId.length >= 1 && pLabelField.length >= 1) {

        

        var vData = pLabelField + "=" + pId;

        jQuery.fn.yiiGridView.update(pGridId, {data: vData});

    };

}



upppp!

Same problem here. I use the search form to filter an attribute which is not displayed in CGridView.

When I change a grid filter, it misses search form filters.