Giter VIP home page Giter VIP logo

yii2-grid's Introduction

Krajee Logo
yii2-grid
Donate       kartikv

Financial Contributors on Open Collective Stable Version Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Yii2 GridView on steroids. A module with various modifications and enhancements to one of the most used widgets by Yii developers. The widget contains new additional Grid Columns with enhanced settings for Yii Framework 2.0. The widget also incorporates various Bootstrap 3.x styling options. Refer detailed documentation and/or a complete demo. You can also view the grid grouping demo here.

GridView Screenshot

Docs & Demo

You can see detailed documentation, demonstration and API code documentation on usage of the extension. You can also view the grid grouping demo here.

Note: If you face an issue of bootstrap popovers loading on page load for editable columns - you can disable it by hiding the bootstrap popovers in your yii2 view layout after document ready. For example in your yii2 view layout:

<script>
$(document).on("ready", function() {
    $('.popover-x:visible').popoverX('hide'); // or use the right CSS selector as per your need
});
</script>

Installation

The preferred way to install this extension is through composer. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

Pre-requisites

Install the necessary pre-requisite (Krajee Dropdown Extension) based on your bootstrap version:

  • For Bootstrap v5.x install the extension kartik-v/yii2-bootstrap5-dropdown
  • For Bootstrap v4.x install the extension kartik-v/yii2-bootstrap4-dropdown
  • For Bootstrap v3.x install the extension kartik-v/yii2-dropdown-x

For example if you are using the Bootstrap v5.x add the following to the require section of your composer.json file:

"kartik-v/yii2-bootstrap5-dropdown": "@dev"

Install

Either run:

$ php composer.phar require kartik-v/yii2-grid "@dev"

or add

"kartik-v/yii2-grid": "@dev"

to the require section of your composer.json file.

Usage

use kartik\grid\GridView;
$gridColumns = [
    ['class' => 'kartik\grid\SerialColumn'],
    [
        'class' => 'kartik\grid\EditableColumn',
        'attribute' => 'name',
        'pageSummary' => 'Page Total',
        'vAlign'=>'middle',
        'headerOptions'=>['class'=>'kv-sticky-column'],
        'contentOptions'=>['class'=>'kv-sticky-column'],
        'editableOptions'=>['header'=>'Name', 'size'=>'md']
    ],
    [
        'attribute'=>'color',
        'value'=>function ($model, $key, $index, $widget) {
            return "<span class='badge' style='background-color: {$model->color}'> </span>  <code>" . 
                $model->color . '</code>';
        },
        'filterType'=>GridView::FILTER_COLOR,
        'vAlign'=>'middle',
        'format'=>'raw',
        'width'=>'150px',
        'noWrap'=>true
    ],
    [
        'class'=>'kartik\grid\BooleanColumn',
        'attribute'=>'status', 
        'vAlign'=>'middle',
    ],
    [
        'class' => 'kartik\grid\ActionColumn',
        'dropdown' => true,
        'vAlign'=>'middle',
        'urlCreator' => function($action, $model, $key, $index) { return '#'; },
        'viewOptions'=>['title'=>$viewMsg, 'data-toggle'=>'tooltip'],
        'updateOptions'=>['title'=>$updateMsg, 'data-toggle'=>'tooltip'],
        'deleteOptions'=>['title'=>$deleteMsg, 'data-toggle'=>'tooltip'], 
    ],
    ['class' => 'kartik\grid\CheckboxColumn']
];
echo GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => $gridColumns,
    'containerOptions' => ['style'=>'overflow: auto'], // only set when $responsive = false
    'beforeHeader'=>[
        [
            'columns'=>[
                ['content'=>'Header Before 1', 'options'=>['colspan'=>4, 'class'=>'text-center warning']], 
                ['content'=>'Header Before 2', 'options'=>['colspan'=>4, 'class'=>'text-center warning']], 
                ['content'=>'Header Before 3', 'options'=>['colspan'=>3, 'class'=>'text-center warning']], 
            ],
            'options'=>['class'=>'skip-export'] // remove this row from export
        ]
    ],
    'toolbar' =>  [
        ['content'=>
            Html::button('&lt;i class="glyphicon glyphicon-plus">&lt;/i>', ['type'=>'button', 'title'=>Yii::t('kvgrid', 'Add Book'), 'class'=>'btn btn-success', 'onclick'=>'alert("This will launch the book creation form.\n\nDisabled for this demo!");']) . ' '.
            Html::a('&lt;i class="glyphicon glyphicon-repeat">&lt;/i>', ['grid-demo'], ['data-pjax'=>0, 'class' => 'btn btn-default', 'title'=>Yii::t('kvgrid', 'Reset Grid')])
        ],
        '{export}',
        '{toggleData}'
    ],
    'pjax' => true,
    'bordered' => true,
    'striped' => false,
    'condensed' => false,
    'responsive' => true,
    'hover' => true,
    'floatHeader' => true,
    'floatHeaderOptions' => ['top' => $scrollingTop],
    'showPageSummary' => true,
    'panel' => [
        'type' => GridView::TYPE_PRIMARY
    ],
]);

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute]

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

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

yii2-grid's People

Contributors

almirb avatar anothersoftware-lv avatar arollmann avatar boehsermoe avatar darcoder avatar deele avatar derekisbusy avatar dvdkrgr avatar fruppel avatar giannisdag avatar gugoan avatar kartik-v avatar kenjebaev avatar lestat1968 avatar monghuz avatar muhammadcahya avatar nbogol avatar newerton avatar niki7har avatar pappfer avatar s1lver avatar sablesoft avatar simialbi avatar spo0okie avatar theill11 avatar thiagotalma avatar udokmeci avatar uldisn avatar vishub avatar xzaero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-grid's Issues

BooleanColumn

In a BooleanColumn I want to use a Select2 as filter widget:

            [
                'class'=>'kartik\grid\BooleanColumn',
                'trueLabel' => 'Pubblicato',
                'falseLabel' => 'Bozza',
                'falseIcon' => '<span class="label label-danger">Bozza</span>',
                'trueIcon' => '<span class="label label-success">Pubblicato</span>',
                'attribute'=>'status',
                'filterType' => GridView::FILTER_SELECT2,
                'filterWidgetOptions' => [
                    'pluginOptions' => [
                        'allowClear' => true
                    ],                    
                ],                
                'vAlign'=>'middle',
            ],

but i can't select empty values to view all rows.
How i can do it to include empty values?

Thanks

disabling export functionality

Setting 'export'=>false to disable export will fail.

Problem is in the init function, when trying to add default values to $this->export

$this->export += [
                'label' => Yii::t('kvgrid', 'Export Data'),
                'icon' => 'export',
                'options' => ['class' => 'btn btn-danger']
            ];

You should test if $this->export is an empty array first

Filter bar disappears after export

Hello Kartik, I have just found a minor issue with the export function. When I perform an export operation the filter bar with all filter fields disappear. They re-appear after a refresh. Your GridView demo page also has the issue, I need to press the "Reset Grid" button after the export operation. Is it something fixable or by design? Thanks in advance.

Export Link Outside grid layout

Hi, I need export button present in grid, outside grid layout i mean in header section of my view. How can i achieve this. Looking forward to hear. Thanks

format number => pageSummary wrong

if I format attribute as number, grid view throws exception
number_format() expects parameter 1 to be double, string given
It works when I change to format as double.
my configuration in grid view:
[
'attribute' => 'totalPrice',
'format' => 'number',
'pageSummary' => true,
]

Reload page before submitting

The parameter "location.reload()" file kv-grid-export.js line 154, is being running before the form is submitted for export.

Application Configuration
Yii Version 2.0.0-dev
Environment dev
Debug Mode Yes
PHP Version 5.5.9

Export action not performed

I use the following code in my index.php

<?php
use app\models\Company;
use app\models\Person;

use yii\helpers\ArrayHelper;
use kartik\helpers\Html;
use kartik\grid\GridView;
?>
// columns 
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => $gridColumns,
        'floatHeader'=>true,
        'floatHeaderOptions'=>['scrollingTop'=>'50'],
        'panel' => [
            'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> '.$this->title.'</h3>',
            'before'=>Html::a('<i class="glyphicon glyphicon-plus"></i> '.Yii::t('app', 'Create {modelClass}',
                    ['modelClass' => 'Person',]),
                    ['create'], ['class' => 'btn btn-success']),
        ],
    ]); ?>

The panels and the export drop-down button showed as expected.
Workflow:
1 - Select of the export options
2 - Alert message popped up
3 - Gridview refreshed...
4 - ... but nothing else happened. (nothing saved)

Did I missed something with the configuration, why the exported file didn't start to download?

Thanks in advanced

monghuz

request

Is possible to place in search grid columns a widget for date range?

new export functionality breaks pjax

The new export functionality will add some html templates to the js code in the response.
pjax searches for <html in response and try to parse it if found :

function extractContainer(data, xhr, options) {
        var obj = {}

        // Prefer X-PJAX-URL header if it was set, otherwise fallback to
        // using the original requested url.
        obj.url = stripPjaxParam(xhr.getResponseHeader('X-PJAX-URL') || options.requestUrl)

        // Attempt to parse response html into elements
        if (/<html/i.test(data)) {
            var $head = $(parseHTML(data.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0]))

Because <html is found in the response, the following line will fail with a Cannot read property '0' of null

Disabling export via export=false will work.

Action Column Widget Setting unknown property vAlign

adding 'vAlign' => GridView::ALIGN_RIGHT to an actionColumn throws this error
the other options don't work either

$gridColumns = [
    'title',
    [
        'class' => '\kartik\grid\BooleanColumn',
        'attribute' => 'active',
        'trueLabel' => 'Yes',
        'falseLabel' => 'No'
    ],
    [
        'class' => '\kartik\grid\DataColumn',
        'attribute' => 'date',
        'filterType' => GridView::FILTER_DATE
    ],
    [
        'class' => 'yii\grid\ActionColumn',
        'vAlign' => GridView::ALIGN_RIGHT
    ],
];

Gridview won't display

Hi, I'm trying to create a gridview but I can't to get it to work, it just doesn't show anything on my view.

I have used Gii to create the searchmodel for a gridview so that should work. I tried a really simple gridview just to test.

I had this on my controller actionIndex()

$searchModel = new \app\models\DotSearch();
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

and this on my view

$dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'id', ], ]); ?>

Demo page incorrectly specifies GridView's namespace

Hello Kartik, not sure how to open issues for the demo page but under the Usage section the use statement is incorrectly specifies the namespace of the GridView widget:

use kartik\widgets\GridView;

// Generate a bootstrap responsive striped table with row highlighted on hover
echo GridView::widget([
    'dataProvider'=> $dataProvider,
    'filterModel' => $searchModel,
    'columns' => $gridColumns,
    'responsive'=>true,
    'hover'=>true
]);

I believe the first line should read:

use kartik\grid\GridView;

suggested overflow property

Suggestion:

Make content of grid table scrollable. Was overflowing the edge - perhaps just my setup?

If responsive set then then there is a div surrounding the table making it easy, however if responsive not set then the div disappears making it impossible to achieve the same thing. Ideally only the table should be scrollable, and panel heading etc should sit still IMHO anyway.

.grid-view .table-responsive {
overflow: auto;
}

Is it possible to use a button dropdown instead of several action buttons?

Hello @kartik-v , I'm coming to you with a question and not a bug. I have 8 possible actions assigned to each row and the action buttons take significant screen estate. I'm wondering if there is a chance for replacing the 8 action buttons with a button dropdown where the user would be able to select the action to take. Is it doable in the current form of the action button implementation? Thank you in advance.

'showPageSummary' error on 0 rows

Greetings and congratulations for the great work you do.

I found the following error:
Unknown method: yii \ grid \ serialcolumn :: renderPageSummaryCell ()

if having no records to display.

regards

Domingo

pjax reload bootstrap stylesheet overriding custom sheet

Refer to this (temporarily) fixed issue for normal grid:
yiisoft/yii2#2310

When I load a grid using pjax, my css is lost and my entire page reverts back to normal bootstrap.css. I'm pretty sure this the same issue as above but I can't work out how to solve. I've tested with normal grid and it works fine, but if I use your grid, the issue arises.

Request - export hidden attributes

Great work, Kartik,

Due to the complexity of some of my grids I can't show all of the attributes on screen, but would like them to be exported. Is there something like the opposite of skip-export (perhaps called include-export) that would hide the attribute on screen but still export it?

Thanks,

José

Minor glitch with the floating header feature

Sorry Kartik, it's me again, please don't hate me too much :) . A small glitch that I found when using floating header. If you open the demo page and start scrolling down everything it works just fine when the browser is on full screen. If you re-size the browser window, let's say it cuts the table in half, when you start scrolling as soon as the floating header kicks in the columns will not be aligned with the column headers any longer. Sorry, it's harder to explain than it actually is. Please let me know if you can see the same glitch or you need more info.

export link under another module

if you load a grind inside an other modules the export link not work because the link ius relativi.

the problem is the action form at line 562 gridView

 if (!is_array($action)) {
            $action = [$action];
        }

adding absolute path

 if (!is_array($action)) {
            $action = ['/'.$action];
        }

FloatHeader option breaks upwards resizing

Hi Kartik,

When floatHeader is enabled and the window is made smaller everything works as expected (column widths get smaller and grid fills the container horizontally...

However once you have made the window small and then begin resizing it upwards to a larger size the grid doesn't fill the container like it should after a certain point (it starts to resize correctly but then suddenly fails).

Using the window maximize button also suffers from this problem.

P.S. Thanks for a great extension however.. Very good!

TouchSpin and Gridview

Hi,
How must i add TouchSpin widget to column in Gridview ?
I tryied demo it such as below:
'value' => function($data) {
return TouchSpin::widget([...]);
},
but I don't see any TouchSpin display on Gridview.
Thanks.

Grid Export Unsupported operand types

I added 'export'=>true to my grid settings and get this error:

 PHP Fatal Error – yii\base\ErrorException
Unsupported operand types

    1. in C:\wamp\www\infoweb-cms\vendor\kartik-v\yii2-grid\grid\GridView.php at line 308
    299300301302303304305306307308309310311312313314315316317



        public function init()
        {
            $module = Yii::$app->getModule('gridview');
            if ($module == null || !$module instanceof \kartik\grid\Module) {
                throw new InvalidConfigException('The "gridview" module MUST be setup in your Yii configuration file and assigned to "\kartik\grid\Module" class.');
            }
            if ($this->export !== false) {
                $this->export += [
                    'label' => Yii::t('kvgrid', 'Export'),
                    'icon' => 'export',
                    'browserPopupsMsg' => Yii::t('kvgrid', 'Disable any popup blockers in your browser to ensure proper download.'),
                    'options' => ['class' => 'btn btn-danger']
                ];

Class 'kartik\widgets\GridView' not found

I tried adding the advanced grid to the advanced template and got this error:

PHP Fatal Error – yii\base\ErrorException
Class 'kartik\widgets\GridView' not found

1. in C:\wamp\www\infoweb-cms\backend\views\news\index.php at line 28
2324252627282930313233

        <?= Html::a(Yii::t('app', 'Create {modelClass}', [
  'modelClass' => 'News',
]), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'title',

2. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderPhpFile() at line 244
3. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderFile() at line 145
4. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Controller.php – yii\base\View::render() at line 300
5. in C:\wamp\www\infoweb-cms\backend\controllers\NewsController.php – yii\base\Controller::render() at line 42
3738394041424344454647

        $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

        return $this->render('index', [
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,
        ]);
    }

    /**
     * Displays a single News model.
     * @param string $id

6. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\InlineAction.php – backend\controllers\NewsController::actionIndex() at line 54
7. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\InlineAction.php – call_user_func_array() at line 54
8. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Controller.php – yii\base\InlineAction::runWithParams() at line 127
9. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Module.php – yii\base\Controller::runAction() at line 434
10. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\web\Application.php – yii\base\Module::runAction() at line 84
11. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Application.php – yii\web\Application::handleRequest() at line 313
12. in C:\wamp\www\infoweb-cms\backend\web\index.php – yii\base\Application::run() at line 17
121314151617

    require(__DIR__ . '/../config/main.php'),
    require(__DIR__ . '/../config/main-local.php')
);

$application = new yii\web\Application($config);
$application->run();

2014-03-25, 11:46:57

Apache/2.4.4 (Win32)

Yii Framework/2.0.0-dev

PHP 5.4.16

This is my view code:

use yii\helpers\Html;
//use yii\grid\GridView;
use kartik\widgets\GridView;

/**

  • @var yii\web\View $this
  • @var yii\data\ActiveDataProvider $dataProvider
  • @var app\models\search\NewsSearch $searchModel
    */

$this->title = Yii::t('app', 'News');
$this->params['breadcrumbs'][] = $this->title;

$gridColumns = [
'title',
'text',
'active',
'date',
];

?>

<h1><?= Html::encode($this->title) ?></h1>

<?php // echo $this->render('_search', ['model' => $searchModel]); ?>

<p>
    <?= Html::a(Yii::t('app', 'Create {modelClass}', [

'modelClass' => 'News',
]), ['create'], ['class' => 'btn btn-success']) ?>

<?= GridView::widget([
    'dataProvider'=> $dataProvider,
    'filterModel' => $searchModel,
    'columns' => $gridColumns,
    'responsive'=>true,
    'hover'=>true
]); ?>

GridView::FILTER_TIME

When set GridView::FILTER_TIME, page reload (infinite loop)

            [
                'attribute' => 'end_time',
                'filterType'=>GridView::FILTER_TIME,
                'filterWidgetOptions' => [
                    'pluginOptions' => [
                        'defaultTime'=>false,
                        'showMeridian' => false,
                        'minuteStep' => 30,
                    ],
                ],

            ],

Support for nowrap in table columns?

Hello Kartik, first of all, thank you for the series of wonderful yii2 extensions, they are life savers. Just a quick request on my end. There is support for horizontal/vertical align out of the box which is great and often used and I think nowrap support could be a nice addition. I know it can be worked around, just wondering if exposing such feature is on your roadmap or something you might want to consider. Thanks a lot again.

yii2-grid with the theme.

screenshot-1
Hiii Kartik i am using yii2-grid with the theme, there is no drop down List for export button.
When i remove this code from the config file then it is work.My theme configuration file is --

'view' => [
'theme' => [
'pathMap' => array('@app/views' => '@webroot/themes/mytheme'),
'baseUrl' => '@web/themes/mytheme'
],
],
And my Grid configuration on config file is ---

'modules' => [
'gridview' => [
'class' => 'kartik\grid\Module',
],
],

This is in view file--

<?php
Pjax::begin(['id' => 'idofyourpjaxwidget']);
echo GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'id' => 'idofyourpjaxwidget',
    'panel' => [
        'type' => 'success',
        'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> Create Session', ['create'], ['class' => 'btn btn-success']),
        'after' => Html::a('<i class="glyphicon glyphicon-repeat"></i> Reset Grid', ['index'], ['class' => 'btn btn-info']),
        'showFooter' => FALSE,
        'beforeOptions' => '',
    ],
    'columns' => [
        ['class' => 'kartik\grid\SerialColumn'],
        'sessionname',
        'startdate',
        'enddate',
        [
            'attribute' => 'createdby0',
            'label' => 'Created By',
            'value' => 'createdby0.username',
        ],
        [
            'class' => 'kartik\grid\BooleanColumn',
            'attribute' => 'ai',
            'label' => 'Active',
            'vAlign' => 'middle',
        ],
        // 'createtime',
        // 'createdby',
        ['class' => 'kartik\grid\ActionColumn'],
    ],
]);
Pjax::end();
?>

Controller is --

public function actionIndex() {
$searchModel = new SessionSearch;
$dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

    if (Yii::$app->request->getIsAjax() || Yii::$app->request->getIsPjax()) {
        return $this->renderAjax('index', [
                    'dataProvider' => $dataProvider,
                    'searchModel' => $searchModel,
        ]);
    } else {
        return $this->render('index', [
                    'dataProvider' => $dataProvider,
                    'searchModel' => $searchModel,
        ]);
    }
}

Thanks for this good module and my solution is advanced ???

Enhancement of Grid Export Features

Enhance grid export features to include:

  1. Ability to preprocess and convert column data to your desired value before exporting. For example convert the HTML formatted icons for BooleanColumn to user friendly text like Active or Inactive after export.
  2. Hide any row or column in the grid by adding one or more of the following CSS classes:
    • skip-export: Will skip this element during export for all formats (html, csv, txt, xls).
    • skip-export-html: Will skip this element during export for html export format.
    • skip-export-csv: Will skip this element during export for csv export format.
    • skip-export-txt: Will skip this element during export for txt export format.
    • skip-export-xls: Will skip this element during export for xls (excel) export format.

These CSS can be set virtually anywhere. For example headerOptions, contentOptions, beforeHeader etc.

Gridview enhancements (export and toolbar)

  • Enable rendering of export without panel by passing {export} variable to grid layout property.
  • Enable rendering of toolbar without panel by passing {toolbar} variable to grid layout property.
  • Revamp export form to be submitted in a new window (in a non-intrusive manner)

Grid Export to Export All Data

Is there a way in the grid to export the entire dataset. As in the grid we would have pagination enabled and the grid export would extract only those number of items in the grid. Can we some how have the export feature extract all items overriding the pagination specified in the grid.

CSV export empty column

When I export grid table to csv format, I get empty columns for the attributes formated as: kartik\grid\BooleanColumn.

I also saw that the ActionColumns are also included as a header in the export, but the column itself has empty rows. Maybe the action column should be hidden by default in any type of export scenarios.

Action url get me to 404 error

i set gridview module in config. but it always get me to /gridview/export/download and that url get me 404 error, i think it must be action url so i looking for controler in gridview widget and i found on file Module.php in line 25 public
$downloadAction = 'gridview/export/download';
i changed it into
public $downloadAction = ['/gridview/export/download'];
and add on line 12
use yii\helpers\Html;
and it works for me.
Thanks for this amazing widget.

Invalid Configuration of Typehead widget in Gridivew

I tried to set a filter in gridview for a string attribute with typehead widget, but I get the error above.

use app\models\Person;

use yii\helpers\ArrayHelper;
use kartik\helpers\Html;
use kartik\grid\GridView;
...
[
        'attribute'=>'position',
        'value'=>'position',
        'filterType'=>GridView::FILTER_TYPEAHEAD,
        'filter'=>ArrayHelper::map(Person::find()->orderBy('position')->asArray()->all(), 'id', 'position'),
        'filterWidgetOptions'=>[
            'pluginOptions' => ['allowClear' => true],
        ],
        'filterInputOptions' => ['placeholder' => 'Type a position'],
        'format'=>'raw'
],

Error stack

1. in C:\xampp-portable\htdocs\yii2\vendor\kartik-v\yii2-widgets\widgets\Typeahead.php at line 78
69707172737475767778798081828384858687    /**
     * Runs the widget
     *
     * @return string|void
     * @throws \yii\base\InvalidConfigException
     */
    public function run()
    {
        if (empty($this->dataset) || !is_array($this->dataset)) {
            throw new InvalidConfigException("You must define the 'dataset' property for Typeahead which must be an array.");
        }
        if (!is_array(current($this->dataset))) {
            throw new InvalidConfigException("The 'dataset' array must contain an array of datums. Invalid data found.");
        }
        $this->validateConfig();
        $this->initDataset();
        $this->registerAssets();
        $this->initOptions();
        echo Html::tag('div', $this->getInput('textInput'), $this->container);
2. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\Widget.php – kartik\widgets\Typeahead::run() at line 96
3. in C:\xampp-portable\htdocs\yii2\vendor\kartik-v\yii2-grid\grid\DataColumn.php – yii\base\Widget::widget(['model' => app\models\search\PersonSearch, 'attribute' => 'position', 'options' => ['placeholder' => 'Type a position'], 'data' => [5 => null, 6 => null, 7 => null, 2 => '', ...], ...]) at line 156
150151152153154155156157158159160161162            }
        }
        if ($this->filterType === GridView::FILTER_CHECKBOX) {
            return Html::activeCheckbox($this->grid->filterModel, $this->attribute, $this->filterInputOptions);
        }
        $options += $this->filterWidgetOptions;
        return $widgetClass::widget($options);
    }

    /**
     * Renders the header cell.
     */
    public function renderHeaderCell()
4. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\grid\Column.php – kartik\grid\DataColumn::renderFilterCellContent() at line 110
5. in C:\xampp-portable\htdocs\yii2\vendor\kartik-v\yii2-grid\grid\DataColumn.php – yii\grid\Column::renderFilterCell() at line 179
173174175176177178179180181182183184185     */
    public function renderFilterCell()
    {
        if ($this->grid->filterModel !== null && $this->mergeHeader && $this->grid->filterPosition === GridView::FILTER_POS_BODY) {
            return null;
        }
        return parent::renderFilterCell();
    }

    /**
     * Store all rows for the column for the current page
     */
    protected function setPageRows()
6. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\grid\GridView.php – kartik\grid\DataColumn::renderFilterCell() at line 400
7. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\grid\GridView.php – yii\grid\GridView::renderFilters() at line 365
8. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\grid\GridView.php – yii\grid\GridView::renderTableHeader() at line 297
9. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\widgets\BaseListView.php – yii\grid\GridView::renderItems() at line 136
10. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\grid\GridView.php – yii\widgets\BaseListView::renderSection('{items}') at line 267
11. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\widgets\BaseListView.php – yii\grid\GridView::renderSection('{items}') at line 113
12. yii\widgets\BaseListView::yii\widgets\{closure}(['{items}'])
13. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\widgets\BaseListView.php – preg_replace_callback('/{\w+}/', Closure, ' <div class="panel panel-defa...') at line 116
14. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\grid\GridView.php – yii\widgets\BaseListView::run() at line 242
15. in C:\xampp-portable\htdocs\yii2\vendor\kartik-v\yii2-grid\grid\GridView.php – yii\grid\GridView::run() at line 418
412413414415416417418419420421422423424        else {
            $this->layout = strtr($this->layout, ['{toolbar}' => $this->toolbar]);
        }
        if ($this->bootstrap && $this->responsive) {
            $this->layout = str_replace('{items}', '<div class="table-responsive">{items}</div>', $this->layout);
        }
        parent::run();
    }

    /**
     * Sets the grid layout based on the template and panel settings
     */
    protected function renderPanel()
16. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\Widget.php – kartik\grid\GridView::run() at line 96
17. in C:\xampp-portable\htdocs\yii2\views\person\index.php – yii\base\Widget::widget(['dataProvider' => yii\data\ActiveDataProvider, 'filterModel' => app\models\search\PersonSearch, 'columns' => [['class' => 'kartik\grid\SerialColumn'], ['attribute' => 'title', 'value' => 'title', 'filterType' => '\kartik\widgets\Select2', 'filter' => ['' => '', 'Ifj.' => 'Ifj.', 'Id.' => 'Id.', 'Prof.' => 'Prof.', ...], ...], 'fullName', ['attribute' => 'company_id', 'value' => Closure, 'filterType' => '\kartik\widgets\Select2', 'filter' => [16 => '168 óra', 17 => '90.9 Jazzy ', 18 => 'A42 Kft.', 19 => 'AAM Consulting', ...], ...], ...], 'floatHeader' => true, ...]) at line 90
848586878889909192        'panel' => [
            'heading'=>'<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> '.$this->title.'</h3>',
            'before'=>Html::a('<i class="glyphicon glyphicon-plus"></i> '.Yii::t('app', 'Create {modelClass}',
                    ['modelClass' => 'Person',]),
                    ['create'], ['class' => 'btn btn-success']),
        ],
    ]); ?>

</div>
18. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\View.php – require('C:\xampp-portable\htdocs\yii2\vi...') at line 315
19. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderPhpFile('C:\xampp-portable\htdocs\yii2\vi...', ['dataProvider' => yii\data\ActiveDataProvider, 'searchModel' => app\models\search\PersonSearch]) at line 247
20. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\View.php – yii\base\View::renderFile('C:\xampp-portable\htdocs\yii2\vi...', ['dataProvider' => yii\data\ActiveDataProvider, 'searchModel' => app\models\search\PersonSearch], app\controllers\PersonController) at line 149
21. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\Controller.php – yii\base\View::render('index', ['dataProvider' => yii\data\ActiveDataProvider, 'searchModel' => app\models\search\PersonSearch], app\controllers\PersonController) at line 362
22. in C:\xampp-portable\htdocs\yii2\controllers\PersonController.php – yii\base\Controller::render('index', ['dataProvider' => yii\data\ActiveDataProvider, 'searchModel' => app\models\search\PersonSearch]) at line 52
46474849505152535455565758        $searchModel = new PersonSearch;
        $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams());

        return $this->render('index', [
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,
        ]);
    }

    /**
     * Displays a single Person model.
     * @param integer $id
     * @return mixed
23. app\controllers\PersonController::actionIndex()
24. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\InlineAction.php – call_user_func_array([app\controllers\PersonController, 'actionIndex'], []) at line 54
25. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\Controller.php – yii\base\InlineAction::runWithParams([]) at line 147
26. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\Module.php – yii\base\Controller::runAction('index', []) at line 423
27. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\web\Application.php – yii\base\Module::runAction('person/index', []) at line 82
28. in C:\xampp-portable\htdocs\yii2\vendor\yiisoft\yii2\base\Application.php – yii\web\Application::handleRequest(yii\web\Request) at line 355
29. in C:\xampp-portable\htdocs\yii2\web\index.php – yii\base\Application::run() at line 12
6789101112 
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');

$config = require(__DIR__ . '/../config/web.php');

(new yii\web\Application($config))->run();
 $_SERVER = array (
  'REDIRECT_MIBDIRS' => '/xampp-portable/php/extras/mibs',
  'REDIRECT_MYSQL_HOME' => '\\xampp\\mysql\\bin',
  'REDIRECT_OPENSSL_CONF' => '/xampp-portable/apache/bin/openssl.cnf',
  'REDIRECT_PHP_PEAR_SYSCONF_DIR' => '\\xampp\\php',
  'REDIRECT_PHPRC' => '\\xampp\\php',
  'REDIRECT_TMP' => '\\xampp\\tmp',
  'REDIRECT_STATUS' => '200',
  'MIBDIRS' => '/xampp-portable/php/extras/mibs',
  'MYSQL_HOME' => '\\xampp\\mysql\\bin',
  'OPENSSL_CONF' => '/xampp-portable/apache/bin/openssl.cnf',
  'PHP_PEAR_SYSCONF_DIR' => '\\xampp\\php',
  'PHPRC' => '\\xampp\\php',
  'TMP' => '\\xampp\\tmp',
  'HTTP_HOST' => 'localhost',
  'HTTP_CONNECTION' => 'keep-alive',
  'HTTP_CACHE_CONTROL' => 'max-age=0',
  'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
  'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36',
  'HTTP_REFERER' => 'http://localhost/yii2/web/company/index',
  'HTTP_ACCEPT_ENCODING' => 'gzip,deflate,sdch',
  'HTTP_ACCEPT_LANGUAGE' => 'hu,en-US;q=0.8,en;q=0.6',
  'HTTP_COOKIE' => '_csrf=5d930bb1f1d3c739662cd783d2b56af4508584b5e08a1864e6a8ca46ea60dda0s%3A32%3A%22M4r5A7lx5LaSMjnHO373LfKPWwmcbpnV%22%3B; PHPSESSID=8pbd2er1chqqci2sct09sue8l7; _identity=ac3866e7f6fd9cf36ddca8bac9609f4fe11b02b0be1e332cf356622a89e25457s%3A46%3A%22%5B1%2C%22Lzo7ifYdKsuviydfhuAK5PYf5ltNLsnN%22%2C2592000%5D%22%3B',
  'PATH' => 'C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\xampp-portable\\php;C:\\Program Files (x86)\\PDFtk\\bin\\;C:\\ProgramData\\ComposerSetup\\bin;C:\\Windows\\idmu\\common',
  'SystemRoot' => 'C:\\Windows',
  'COMSPEC' => 'C:\\Windows\\system32\\cmd.exe',
  'PATHEXT' => '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
  'WINDIR' => 'C:\\Windows',
  'SERVER_SIGNATURE' => '
Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7 Server at localhost Port 80

',
  'SERVER_SOFTWARE' => 'Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7',
  'SERVER_NAME' => 'localhost',
  'SERVER_ADDR' => '::1',
  'SERVER_PORT' => '80',
  'REMOTE_ADDR' => '::1',
  'DOCUMENT_ROOT' => 'C:/xampp-portable/htdocs',
  'REQUEST_SCHEME' => 'http',
  'CONTEXT_PREFIX' => '',
  'CONTEXT_DOCUMENT_ROOT' => 'C:/xampp-portable/htdocs',
  'SERVER_ADMIN' => 'postmaster@localhost',
  'SCRIPT_FILENAME' => 'C:/xampp-portable/htdocs/yii2/web/index.php',
  'REMOTE_PORT' => '54267',
  'REDIRECT_URL' => '/yii2/web/person/index',
  'GATEWAY_INTERFACE' => 'CGI/1.1',
  'SERVER_PROTOCOL' => 'HTTP/1.1',
  'REQUEST_METHOD' => 'GET',
  'QUERY_STRING' => '',
  'REQUEST_URI' => '/yii2/web/person/index',
  'SCRIPT_NAME' => '/yii2/web/index.php',
  'PHP_SELF' => '/yii2/web/index.php',
  'REQUEST_TIME_FLOAT' => 1400273378.348,
  'REQUEST_TIME' => 1400273378,
);

Action Column

'deleteOptions' => ['label' => 'test']
Works only with the first line

request

Kartik: What do you think of an extension kartik/reports/ReportView; for printing and/or exporting in various formats. The report will be defined by panels type, which would come to be sections (header, group header, body, footer, group, foot). At least part of the work is already done with TabularForm and GridView. TabularForm :: INPUT_STATIC to display the values​​, CSS and more formatting with Bootstrap columm. There may be an interface for the user to define reports; kartik/reports/ReportDesigner.

Problem while exporting the grid

I am getting the below given error while using the export functionality to export the grid

Unable to resolve the request "assets/788d3d4f/js/kv-grid.js"

I look in the assests folder and i can find the js, could you please support in resolving the issue.

floatHeader in inner scrolling doesnt work

<?= GridView::widget([
...
'floatHeaderOptions' => ['scrollContainer' => 'function...']

string 184 of assets "jquery.floatThead.js" work with error "property 'scrollContainer' is not a function"
because property 'scrollContainer' of object passed as a string:

Object
...
 scrollContainer: "function...",
...

but correct is:

Object
...
 scrollContainer: function...,
...

Export encoding

It would be nice to support character encoding of the exported files.
For example. due to Excel's limitation, if I have accented characters in my utf-8 encoded darabase, like 'árvíztűrő tükörfúrógép', I need to convert it to iso-8859-2, to appear in Excel correctly. When opening utf-8 file, the accented characters break.

It occurs as CSV and as Excel too, so I would need to configure it to convert the rows to iso-8859-2 before export.

MySql Views in GridView

GridView can not determine primary key column in a view and therefore does not detect the id stored in a MySql view consequently can not view, update or delete records in related tables.

Is there any solution?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.