Cześć,
Wiem,ze dużo jest takich topiców, ale żaden nie rozwiązał mojego problemu. Otóż: po wpisaniu w polu wyszukiwania w cgridview zupelnie nic sie nie dzieje, nic nie daje enter. Nie pokazuje sie to "kołeczko", które kreci sie gdy sie laduje cgridview.
Moj model:
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('title, short, text, date, author, category', 'required'),
array('author, category', 'numerical', 'integerOnly'=>true),
array('title, photo', 'length', 'max'=>255),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, title, short, text, date, author, photo, category, categories.name', 'safe', 'on'=>'search'),
);
}
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('title',$this->title,true);
$criteria->compare('short',$this->short,true);
$criteria->compare('text',$this->text,true);
$criteria->compare('date',$this->date,true);
$criteria->compare('author',$this->author);
$criteria->compare('photo',$this->photo,true);
$criteria->compare('category',$this->category);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
Widok:
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider' => $news->search(),
'filter' => $news,
'itemsCssClass' => 'table table-striped',
'pagerCssClass'=>'button-group float-right',
'pager'=>array ('maxButtonCount'=>5,
'nextPageLabel'=>'<i class="glyph-icon icon-chevron-right"></i>',
'prevPageLabel'=>'<i class="glyph-icon icon-chevron-left"></i>',
'lastPageLabel' => '',
'firstPageLabel' => '',
'header' => '',
'cssFile' => Yii::app()->getBaseUrl(true) . '/public/cms/assets/css/pager.css',
),
'summaryText' => '<p class="font-gray-dark">{start} - {end} z {count} rekordów</p>',
'columns' => array(
'title',
array(
'name' => 'category',
'type' => 'raw',
'value' => '$data->categories->name',
),
array(
'name' => 'author',
'type' => 'raw',
'value' => '$data->fullName()',
),
array(
'name' => 'date',
'type' => 'raw',
'value' => '$data->date',
),
array('class'=>'CButtonColumn',
'template'=>'{view} {update} {delete}',
'buttons'=>array (
'view'=>array(
'label' => '<i style="font-size: 1.4em;" title="Zobacz" class="glyph-icon icon-search"></i>',
'imageUrl' => false,
'options'=>array("target"=>"_blank"),
),
'update'=> array(
'label' => '<i style="font-size: 1.4em;" title="Edytuj" class="glyph-icon icon-edit"></i>',
'imageUrl' => false,
),
'delete'=>array(
'label' => '<i style="font-size: 1.4em;" title="Usuń" class="glyph-icon icon-trash-o"></i>',
'imageUrl' => false,
),
),
),
),
));
?>
I Controller:
public function actionIndex()
{
$news = new News;
$news->unsetAttributes(); // clear any default values
if(isset($_GET['News']))
$news->attributes=$_GET['News'];
$this->render('index', array('news' =>$news));
}
jquery załączone.
Mimo to nie działa…
Proszę o pomoc.
Pozdrawiam,
B.