Hi everybody!
I am really getting stuck in a problem I can't understand.
the problem
Given a certain Model ('Struttura': ['codice_struttura', 'codice_regione', ... ])
I am trying to build a custom search page with a jvectormap, some dropdown and a CGridView.
Clicking on the map, users select a region.
A js function will:
Currently I can perform an ajax update of the dropdown but I cannot update the CGridView.
the code
search.php
StrutturaController.php
_recuperaDatiComune.js
Firebug console logs:
When I manually filter the CGridView I get the same GET request
obviously in the Model:
so, why the CGridView doesn't display filtered data?
Thanks in advance for your help and for all the topics I snooped so far
I am really getting stuck in a problem I can't understand.
the problem
Given a certain Model ('Struttura': ['codice_struttura', 'codice_regione', ... ])
I am trying to build a custom search page with a jvectormap, some dropdown and a CGridView.
Clicking on the map, users select a region.
A js function will:
- update one dropdown with the list of cities
- filter the CGridView by 'codice_regione' in order to find the 'Struttura' in that region
- ...
Currently I can perform an ajax update of the dropdown but I cannot update the CGridView.
the code
search.php
[..some other stuff..] <div id="mapData"> <?php $this->widget('bootstrap.widgets.TbGridView', array( 'type'=>'striped bordered condensed', 'id'=>'strutture-grid', 'dataProvider'=>$model->search(), 'filter'=>$model, )); ?> </div> [..some other stuff..]
StrutturaController.php
//[..some other stuff..] public function actionSearch() { $uri = Yii::app()->baseUrl . '/js/jquery-jvectormap-1.1.1.css'; Yii::app()->clientScript->registerCssFile($uri, 'screen, projection'); $model=new Struttura('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['Struttura'])){ $model->attributes=$_GET['Struttura']; } $this->render('search', array('model'=>$model)); } //[..some other stuff..]
_recuperaDatiComune.js
[..some other stuff..] if(region_id !== false) { $.fn.yiiGridView.update("strutture-grid", {data: {codice_regione:region_id}}); } [..some other stuff..]
Firebug console logs:
GET /.../index.php?r=struttura%2Fsearch&codice_regione=16&ajax=strutture-grid GET /.../index.php?r=struttura/jSbrowse&id=16
When I manually filter the CGridView I get the same GET request
GET /.../index.php?r=struttura%2Fsearch&codice_regione=16&ajax=strutture-grid
obviously in the Model:
public function search() { $criteria=new CDbCriteria; $criteria->compare('codice_regione',$this->codice_regione,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, )); }
so, why the CGridView doesn't display filtered data?
Thanks in advance for your help and for all the topics I snooped so far
