Answer the question
In order to leave comments, you need to log in
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;',
),
),
),
));
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,
));
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question