Я гуглил везде, и я просто не вижу, что еще мне не хватает? Фильтр сверху ничего не делает. Я думаю, что это дефолт от crud, не уверен. Что еще мне здесь не хватает?
контроллер:
$model=new Product('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Product']))
$model->attributes=$_GET['Product'];
$this->render('view',array(
'model'=>$model,
));
правила модели:
array('product_id, product_name,product_price, product_status, 'safe', 'on'=>'search'),
и просмотр:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'product-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'product_id',
'product_name',
'product_price',
'product_status',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
поиск модели, почти по умолчанию
$criteria=new CDbCriteria;
$criteria->compare('product_id',$this->product_id);
$criteria->compare('product_name',$this->product_name);
$criteria->compare('product_price',$this->product_price);
$criteria->compare('product_status',$this->product_status);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
js
jQuery(function($) {
$('.search-button').click(function(){
$('.search-form').toggle();
return false;
});
$('.search-form form').submit(function(){
$('#product-grid').yiiGridView('update', {
data: $(this).serialize()
});
return false;
});
jQuery(document).on('click','#product-grid a.delete',function() {
if(!confirm('Are you sure you want to delete this item?')) return false;
var th = this,
afterDelete = function(){};
jQuery('#product-grid').yiiGridView('update', {
type: 'POST',
url: jQuery(this).attr('href'),
success: function(data) {
jQuery('#product-grid').yiiGridView('update');
afterDelete(th, true, data);
},
error: function(XHR) {
return afterDelete(th, false, XHR);
}
});
return false;
});
jQuery('#product-grid').yiiGridView({'ajaxUpdate':['product-grid'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'items','selectableRows':1,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'Product_page'});
App.setMainPage(true);
App.init();
App.setTableDetails(jsonDashboard);
});
/*]]>*/
search()
вашей модели? - person DaSourcerer   schedule 28.11.2013$this->render('view',...)
, действительно предполагаемым? то есть это не вид, где вы хотели индекс? - person DaSourcerer   schedule 28.11.2013