Yii2 Grid

Just opened up this extension for release and working on the demo page. The extension includes various enhancements to the GridView widget and enhanced/new grid columns. Refer documentation details and features here and let know of any feedback.

FYI - the [size="4"]DEMO PAGE[/size] is online for this extension. The demo doubles up as a GridView configurator as well. You can configure various widget options dynamically and see the impact.

Great work, once again.

Thank you very much!

This is really awesome! Not only is the extension great, but you are supporting it nicely with the demo page, so we can see how it works and how cool the features really are.

I have looked at your other work at http://demos.krajee.com/ and you are building a very impressive set of tools for Yii 2.0. So far I have used your Yii2 Social module and your wiki on relationships.

Ultimately, I will probably use all your tools because I can see how useful they are. It’s really great work, thanks for bringing so much to the Yii 2.0 framework so quickly.

Thanks. You may post feedback of your use in the extension forum or record any issue faced on github.

First, Thanks for this awesome widget and new export ability. i have already try your grid widget but when i clicking export to csv/text/html/excel it bring me to ‘gridview/export/download’ like mentioned in module. But in my experience that action(gridview/export/download) generate 404 not found when that action launched. sorry for my bad english. Thanks

Refer to the documentation. You must setup and add a module named gridview in the modules section of your Yii Configuration file.

I try grid with filter type “GridView::FILTER_DATE”, it works. but when i using filter widget option and add option ‘type’ => DatePicker::TYPE_COMPONENT_APPEND, it gave me error “Class ‘DatePicker’ not found” also when i add ‘options’ => [‘placeholder’ => ‘Enter date …’] it not works but not giving error.

when i try grid using filter type "GridView::FILTER_TIME", time picker show up on grid but the page kept refreshed again and again. sorry for my bad english in my explanation. Any ideas maybe i missing something in my setting

this is my code in index.php




<?=

    GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'hover' => true,

        'responsive' => true,

        'bootstrap' => 'true',

        'columns' => [

            ['class' => 'yii\grid\SerialColumn'],

            //'id',

            'mobile_phone',

            [

                'attribute' => 'date',

                'filterType' => GridView::FILTER_DATE,

                'filterWidgetOptions' => [

                    'options' => ['placeholder' => 'Enter date ...'], //this code not giving any changes in browser

                    'type' => DatePicker::TYPE_COMPONENT_APPEND, //this give error Class 'DatePicker' not found

                    'pluginOptions' => [

                        'autoclose' => true,

                        'format' => 'yyyy-mm-dd'

                    ],

                ],

            ],

            'in_time',

            [ //this in where i put code to add time picker

                'attribute' => 'out_time',

                'filterType' => GridView::FILTER_TIME,

                'filterWidgetOptions' => [

                    'pluginOptions' => [

                        'showSeconds' => true,

                        'showMeridian' => false,

                        'minuteStep' => 1,

                        'secondStep' => 1,

                        'disableMousewheel' => false

                    ]

                ],

            ],

            [

                'attribute' => 'status',

                'value' => function ($model, $index, $widget) {

            return $model->getStatusText();

        },

                'filter' => array("O" => "Out Of Town", "B" => 'Blank', "R" => "Revisi"),

            ],

            ['class' => 'yii\grid\ActionColumn'],

        ],

        'panel' => [

            'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> Data Absen </h3>',

            'type' => 'success',

            'before' => (Html::a('<i class="glyphicon glyphicon-plus"></i> Create Absen', ['create'], ['class' => 'btn btn-success']) . '&nbsp;' . Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['index'], ['class' => 'btn btn-info'])),

            'showFooter' => false

        ],

    ]);

    ?>



The NAMESPACE folks! Use fully namespaced classes always. You may learn about using PHP Namespaces if its not clear. This is very important if you are coding in Yii2 and > PHP v5.3

For your case, this should work:




//

'type' => \kartik\widgets\DatePicker::TYPE_COMPONENT_APPEND

//



or this




use kartik\widgets\DatePicker;

//

'type' => DatePicker::TYPE_COMPONENT_APPEND

//



Yes, it works. Thank you. Can i add date picker using type date range in grid? when i add time picker the page keeps reloading, i add using code like this


[

                'attribute' => 'out_time',

                'filterType' => GridView::FILTER_TIME,

                'filterWidgetOptions' => [

                    'pluginOptions' => [

                        'showSeconds' => true,

                        'showMeridian' => false,

                        'minuteStep' => 1,

                        'secondStep' => 1,

                        'disableMousewheel' => false

                    ]

                ],

            ],

Hello Kartik,

I am using your widget grid and it working awesome but I have a little question, can we use price range as filter like I need something like first I select any condition in dropdown like <, >, <=, >= and etc and then a text box where I can enter digit so now the filter result will be combination of condition and digit. Like get all products whose price is <= 10.

I just need to ask is it possible in your grid widget? If yes then please let me know how as soon as possible.

Thanks in advance.

Not exactly to the level of operator comparison as you have - because the filter functionality mostly is still yii2 default which is a simple form submission.

But you could achieve the ranges for various use cases by using special filter widgets like INPUT_SLIDER and DATE_RANGE (from my other extensions).

HI kartik,

i store timestamp in database and i want to filter dusing datepicker so please help me how to i filter date…?

in yii2 define editable grid under subgrid and how it possible

Hi! Firstly thank you for a great extension and I have one question but I am not sure if it is right for this forum so please forgive my ignorance. I am new to Yii2 world.

Question is:

I have two gridviews that originate from the same model and are placed on the same page. I need it that way because grids show different sets of data. Now problem: when I apply date-rage filter it gets id composed of classname-attribute (id=“documents-assigned_at”) and in the first grid everything works as expected but in the second grid date-rage filter does not initialize at all. I suppose it is due to the same id value but I can not change it. I’ve tried in many ways but I guess when date-range and any other of your widgets are assigned as filters to some gridview it internally overwrites id value to classname-model attribute. Is it possible to change id for widgets when they are used as filters?

Same problem is with Select2 widget, for example.

Thanks in advance.