Yii TbExtendedGridView Configurations

The following removes pagination:

   'template' => "{items}",

The following gives a row effect (without column divider)

   // add
   'itemsCssClass' => 'table-cgrid items',
   // remove
   'type'=>'striped bordered',

The header will float if there are many rows

   'fixedHeader' => TRUE,

Apache2 enable .htaccess

To make .htaccess files work as expected, you need to edit this file:

    /etc/apache2/sites-available/default

Look for a section that looks like this:

    
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # Uncomment this directive is you want to see apache2's
                # default start page (in /apache2-default) when you go to /
                #RedirectMatch ^/$ /apache2-default/
    

You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it’s okay to allow .htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect:

    sudo /etc/init.d/apache2 reload

Make sure Apache .htaccess is enabled (by default it is enabled in Ubuntu)

    sudo a2enmod rewrite

Cheers 🙂

Yii TbExtendedGridView – TypeError: url is undefined

You may encounter a problem in Yii TbExtendedGridView:
TypeError: url is undefined
When you click the header or filter on the grid, the solution is simple just add the following to ExtendedGridView.

  $this->widget('bootstrap.widgets.TbExtendedGridView', array(
      ... 
      ajaxUrl'=> Yii::app()->request->getUrl(),
      ...

Yii model findBySql does not return related data

Yii model findBySql does not return related data but returns only its own fields. To get around it always use model like:

       $model = User::model()->with('posts')->find ....

Now model fetch related data from posts table as well.

However this won’t work.

       $model = User::model()->findBySql('select * from user inner join posts on ....) ....

Yii csqldataprovider with cgridview – trying to get property of non object

When using yii csqldataprovider with cgridview in Yii framework and csqldataprovider has sql from related tables you might get the error in the header (edit, delete, update) column. To solve this issue don’t use the default column :

			array(
			        'header' => Yii::t('ses', 'Edit'),
			        'class' => 'bootstrap.widgets.TbButtonColumn',
			),

instead use:

			array(
				'header' => Yii::t('ses', 'Edit'),
				'class' => 'bootstrap.widgets.TbButtonColumn',
				"template"=>"{update} {delete}",
				'updateButtonUrl' => 'Yii::app()->createUrl("Controller/update/" . $data["id"])',
				'deleteButtonUrl' => 'Yii::app()->createUrl("Controller/delete/" . $data["id"])',
			),