Yii 2.0: yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.

The yii2-dynagrid module is a great complementary addition to the kartik-v/yii2-grid module, enhancing it with personalization features. It turbo charges your grid view by making it dynamic and personalized for each user. It allows users the ability to set and save their own grid configuration. The major features provided by this module are:

  • Personalize, set, and save grid page size at runtime. You can set the minimum and maximum page size allowed.
  • Personalize, set, and save grid data filters at runtime. A user can define and save his/her own personalized grid data filters.
  • Personalize, set, and save grid column sorts at runtime. A user can define and save his/her own personalized grid column sorts.
  • Personalize the grid columns display through drag and drop. Reorder grid columns and set the visibility of needed columns, and allow users to save this setting. Control which columns can be reordered by users through predefined columns setup. Predetermine which of your desired columns will be always fixed to the left or right by default.
  • Personalize grid appearance and set the grid theme. This will offer advanced customization to the grid layout. It allows users to virtually style grid anyway they want, based on how you define themes and extend them to your users. Since the extension uses the yii2-grid extension,it offers all the styling options the yii2-grid extension provides, including the various grid column enhancements, bootstrap panels, and other grid styles. This will allow you to easily setup themes for users in many ways. You have an ability to setup multiple themes in your module configuration, and allow users to select one of them. The extension by default includes some predefined themes for you to get started.
  • Allow you to save the dynamic grid configuration specific to each user or global level. Implements a DynaGridStore object to manage dynagrid personalizations independent of storage. One of the following storage options are made available to store the personalized grid configuration:
    • Session Storage (default)
    • Cookie Storage
    • Database Storage
  • The extension automatically validates and loads the saved configuration based on the stored settings.

Note: This extension depends on the kartik-v/yii2-grid extension which in turn depends on the yiisoft/yii2-bootstrap extension. Check the composer.json for this extension's requirements and dependencies. Note: Yii 2 framework is still in active development, and until a fully stable Yii2 release, your core yii2-bootstrap packages (and its dependencies) may be updated when you install or update this extension. You may need to lock your composer package versions for your specific app, and test for extension break if you do not wish to auto update dependencies.

Latest Release

The latest version of the module is v1.2.0 released on 25-Oct-2014. Refer the CHANGE LOG for details.

  • With v1.2.0, the Dynagrid is revamped to include a DynaGridStore object and ability to save, update, or delete grid personalizations including grid filter and sort.

  • With v1.1.0, the DynaGrid includes Pjax support. To enable Pjax processing, set gridOptions['pjax'] property to true and control pjax behavior using gridOptions['pjaxSettings'].


You can see detailed documentation or view a complete demo on usage of the extension.


The preferred way to install this extension is through composer.

Note: Before you install, remember to check if the minimum-stability is set to dev in your composer.json file in the application root.

Either run:

$ php composer.phar require kartik-v/yii2-dynagrid "*"

or add:

"kartik-v/yii2-dynagrid": "*"

to the require section of your composer.json file.



Setup the module in your Yii configuration file with a name dynagrid as shown below. In addition, you must also register the gridview module as described in the yii2-grid documentation.

'modules' => [
   'dynagrid' =>  [
        'class' => '\kartik\dynagrid\Module',
        // other settings (refer documentation)
    'gridview' =>  [
        'class' => '\kartik\grid\Module',
        // other module settings


The DynaGrid widget can be used to render the personalized & dynamic version of kartik\Grid\GridView in the following way:

use kartik\dynagrid\DynaGrid;
use kartik\grid\GridView;
$columns = [
    ['class'=>'kartik\grid\SerialColumn', 'order'=>DynaGrid::ORDER_FIX_LEFT],
        'filterWidgetOptions' => [
            'pluginOptions' => ['format' => 'yyyy-mm-dd']
    ['class'=>'kartik\grid\CheckboxColumn',  'order'=>DynaGrid::ORDER_FIX_RIGHT],
echo DynaGrid::widget([
    'columns' => $columns,
        'panel'=>['heading'=>'<h3 class="panel-title">Library</h3>'],

Tip: You need to be careful, in case you are using the new \kartik\grid\FormulaColumn in your grid layout. The reordering of columns by users will render your formulae invalid, since the column indices will change. It is recommended, you set the order of all such formulae columns and its dependencies to the DynaGrid::ORDER_FIX_LEFT, so that such column positions are pre-fixed.



yii2-dynagrid is released under the BSD 3-Clause License. See the bundled LICENSE.md for details.


Total 8 comments

#19110 report it
Michel Braidy at 2015/03/19 05:23pm
search is not working

after setting dynagrid in index.php, the search stopped working. Can you please help Thank you

#18406 report it
Kartik V at 2014/10/24 04:30pm
Re: well done! thx.

thanks for the feedback scott - the latest release v1.2.0 is now released which supports saving of grid filters and sorts in addition to pagesize, columns order, and theme.

#18202 report it
Scott_Huang at 2014/09/25 11:32am
well done! thx.

well done! thx.

#17665 report it
Kartik V at 2014/07/13 05:56am

@sltech the example is updated to include the correct namespace

#17664 report it
Kartik V at 2014/07/13 05:55am
Minimum Stability

@sltech the instructions have been updated in the installation section. Before installation, you must remember to check if the minimum-stability is set to dev in your composer.json file in the application root.

#17662 report it
sltech at 2014/07/12 07:30am
namespace is wrong

The namespace in the usage code would be

use kartik\dynagrid\DynaGrid;

#17660 report it
sltech at 2014/07/12 06:17am
worked by changing "minimum-stability": "dev" in composer.json

worked by changing "minimum-stability": "dev" in composer.json, thank you

#17659 report it
sltech at 2014/07/12 04:21am
unable to install

please help

getting not found error

C:\bin>php composer.phar require kartik-v/yii2-dynagrid "*" ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.

Problem 1 - The requested package kartik-v/yii2-dynagrid could not be found in any ver sion, there may be a typo in the package name.

Leave a comment

Please to leave your comment.

Create extension
No downloadable files yet