Hi,
I have two model variablecategory and variable.
variablecategory
id categoryname description
1 State list of state’s
2 Setup category Telco,Cosultant,Tech Agencies & Local Council
3 Negeri Sembilan’s District Names
variable table
id name description fkvariablecategoryid
1 Nilai N.S district name 3 [->]
2 Putrajaya District name 3 [->]
3 Cyberjaya District name 3 [->]
4 Tampin N.S district name 3 [->]
5 Jempol N.S district name 3 [->]
6 Kuala Pilah N.S district name 3 [->]
fkvariablecategoryid is the foreign key of variablecategory table.
i has combined this two model into one view using tbgridview.
view
<?php
/* @var $this VariablecategoryController */
/* @var $model Variablecategory */
$this->breadcrumbs=array(
'General Setup',
'Manage',
);
$this->menu=array(
//array('label'=>'List Variablecategory', 'url'=>array('index')),
array('label'=>'Create Variable Category', 'url'=>array('create')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#variablecategory-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
");
?>
<h1><a href="#"><img class="pagetitleicon" src="<?php echo Yii::app()->theme->baseUrl; ?>/images/big_icons/icon-grid.png" alt="Page" /></a>
General Setup</h1>
<h4>View General Setup :
<?php $this->widget('bootstrap.widgets.TbLabel', array(
'type'=>'info', // 'success', 'warning', 'important', 'info' or 'inverse'
'label'=>'Item',
)); ?></h4>
<p>
You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<!--?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?-->
<div class="search-form" style="display:none">
<!--?php $this->renderPartial('_search',array(
'model'=>$model,
)); ?-->
</div><!-- search-form -->
<div class="span-23">
<?php
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id'=>'variablecategory-grid',
'sortableRows'=>true,
'afterSortableUpdate' => 'js:function(id, position){ console.log("id: "+id+", position:"+position);}',
'type'=>'striped bordered condensed hover',
'dataProvider'=>$model->search(),
'ajaxUpdate'=>false,
'filter'=>$model,
'enablePagination' => True,
'columns'=>array(
array(
'name'=>'id',
'filter'=>false,
'value'=>'$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1', // row is zero based
'headerHtmlOptions' => array('style'=>'width:3%'),
),
array(
'name'=>'categoryname',
//'filter'=>CHtml::activeTextField($model2,'fkvariablecategoryid'),
),
'description',
array(
'class'=>'CButtonColumn',
'template' => '{view}{update}{delete}',
'viewButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/framework/view.png',
'updateButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/framework/edit.png',
'deleteButtonImageUrl'=>Yii::app()->request->baseUrl.'/images/framework/delete.png',
)),
)); ?>
</div>
<h4>View General Setup :
<?php
$this->widget('bootstrap.widgets.TbLabel', array(
'type'=>'info', // 'success', 'warning', 'important', 'info' or 'inverse'
'label'=>'Item Values',
)); ?></h4>
<!--Operations menu-->
<p>
You may optionally enter a comparison operator (<b><</b>, <b><=</b>, <b>></b>, <b>>=</b>, <b><></b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
<div class="span-23">
<?php
$widtha = 'width:7%;';
$widthb = 'width:30%;';
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id'=>'variable-grid',
'type'=>'striped bordered condensed hover',
'sortableRows'=>true,
'afterSortableUpdate' => 'js:function(id, position){ console.log("id: "+id+", position:"+position);}',
'dataProvider'=>$model2->search(),
//'template'=>"{items}\n{pager}",
'filter'=>$model2,
'enablePagination' => True,
'ajaxUpdate'=>false,
'columns'=>array(
array(
'name'=>'id',
'filter'=>false,
'value'=>'$this->grid->dataProvider->pagination->currentPage*$this->grid->dataProvider->pagination->pageSize + $row+1', // row is zero based
'headerHtmlOptions' => array('style'=>'width:3%'),
),
'name',
'description',
array(
'name'=>'fkvariablecategoryid',
//'filter'=>CHtml::activeTextField($model,'categoryname'),
'value'=>'Variable::getSwitch($data->fkvariablecategoryid)',
),
array(
'class'=>'CButtonColumn',
'template' => '{view}{update}{delete}',
'buttons'=>array(
'view' => array
(
'url'=>'Yii::app()->createUrl("variable/view", array("id"=>$data->id))',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/framework/view.png'
),
'update' => array
(
'url'=>'Yii::app()->createUrl("variable/update", array("id"=>$data->id))',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/framework/edit.png'
),
'delete'=>array(
'url'=>'Yii::app()->createUrl("variable/delete", array("id"=>$data->id))',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/framework/delete.png'
),
'afterDelete'=>'function(link,success,data){ if(success) $("#statusMsg").html(data); }',
)
)
),
));
?>
</div>
Now the question is - i want to filter variable tbgridview as well as the variablecategory the moment when i filter some value in the field -> category name.both tbgridview for variablecategory and variable should filter together.
so far i used this code in variablecategory tbgridview:
//‘filter’=>CHtml::activeTextField($model2,‘fkvariablecategoryid’),
yes it is filtering the variable value in tbgridview but its not filtering the variablecategory value.
attached is the picture of the view
pls guide me.
thank you.