M
M
Mokhirjon Naimov2015-09-15 17:22:18
Yii
Mokhirjon Naimov, 2015-09-15 17:22:18

All data is not displayed through CGridView, how does it display all data?

There is this code:

$this->widget('zii.widgets.grid.CGridView', array(
    'id'            => 'addressesListGrid',
    'dataProvider'  => $addresses->search(),
    'template'      => '{items}',
    'itemsCssClass' => 'table',
    
    'columns' => array(
        'user_id',
        'street',
        'home',
        'main',
    ),
));

But data is output only with the value 'main' = 0 (main only accepts 0 and 1). What should be done to display all the data, that is, without a filter?
Tried to do this (displays an error):
...
    'dataProvider'  => $addresses->search(),
    'filter' => false,
...

Also like this (unsuccessfully):
...
    'columns' => array(
        'user_id',
        'street',
        'home',
       array(
            'name' => 'main',
            'filter'  => false,
       ),
    ),
...

search method:
public function search()
  {
    $criteria = new CDbCriteria;

    $criteria->compare('id', $this->id);
    $criteria->compare('user_id', $this->user_id);
    $criteria->compare('area_id', $this->area_id);
    $criteria->compare('zone_id', $this->zone_id);
    $criteria->compare('street', $this->street);
    $criteria->compare('home', $this->home);
    $criteria->compare('main', $this->main);

    return new CActiveDataProvider($this, array(
      'criteria' => $criteria,
    ));
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valery, 2015-09-25
@supervaleha

Let's first understand where the error is. Did you look at the request itself in the profiler? Dump criteria did?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question