T
T
The Dragger2015-05-06 09:49:05
Yii
The Dragger, 2015-05-06 09:49:05

Why doesn't output data from bd TbGridView in yii1?

Widget itself

$modelMahala = new RefMahala();
        $dataProvider = $modelMahala->search();
        if($dataProvider != null){
            $this->widget('bootstrap.widgets.TbGridView', array(
                'id'=>'vacancies-grid',
                'type'=>'striped',
                'ajaxUpdate' => true,
                'dataProvider'=>$dataProvider,
                'template' => '{items}{pager}',
                'columns'=>array(
                    array('name'=>'id', 'header'=>'№', 'htmlOptions'=>array('style'=>'width: 0px'),),
                    'name::'.Yii::t('mahala','Махаля'),
                    array(
                        'class'=>'CButtonColumn',
                        'template'=>'{myview}',
                        'buttons'=>array(
                            'myview'=>array(
                                'url'=>'Yii::app()->createUrl("tools/mahala", array("id"=>$data["id"]))',
                                'label' => Yii::t('service','Просмотр'),
                                'options'=>array('class' => 'btn', 'style' => 'width:150px;'),
                            ),
                        ),
                        'htmlOptions'=>array(
                            'style'=>'width:100px;',
                        ),
                    ),
                ),
            ));

the model itself
public function search()
  {
    // @todo Please modify the following code to remove attributes that should not be searched.
    $language = Yii::app()->language;
    $criteria=new CDbCriteria;

    $criteria->compare('id',$this->id);
    $criteria->compare('district_id',$this->district_id);
    $criteria->compare('name_ru',$this->name_ru,true);
    $criteria->compare('name_uz',$this->name_uz,true);
    $criteria->compare('name_en',$this->name_en,true);
    $criteria->compare('address_ru',$this->address_ru,true);
    $criteria->compare('address_uz',$this->address_uz,true);
    $criteria->compare('address_en',$this->address_en,true);
    $criteria->compare('sort',$this->sort);
    $criteria->compare('active',$this->active);

    $criteria->select = 'id, name_'.$language.' AS "name"';

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

id displays but name does not display why?
the first time I made a mistake, I loaded the names from the wrong model, but they loaded, but they don’t want to from another model, although the names of the fields in the table are identical with which they first loaded.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vyachin, 2015-05-08
@vyachin

name is not in your table schema. It's easier for you to specify the desired field through an array of columns

$modelMahala = new RefMahala();
        $dataProvider = $modelMahala->search();
        if($dataProvider != null){
            $this->widget('bootstrap.widgets.TbGridView', array(
                 .......
                'columns'=>array(
                    ....
                    'name_'.Yii::app()->language.':text:'.Yii::t('mahala','Махаля'),

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question