kartik-v / yii2-dynagrid Goto Github PK
View Code? Open in Web Editor NEWTurbo charge the Yii 2 GridView with personalized columns, page size, and themes.
Home Page: http://demos.krajee.com/dynagrid
License: Other
Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.
Home Page: http://demos.krajee.com/dynagrid
License: Other
{"page":"10","keys":["7ca9c5d6","e3568eca","017e9e28"],"theme":"panel-primary"}
$columns = [
'nome_fantasia',
'cnpj',
[
'label' => 'Endereço',
'attribute' => 'endereco',
'value' => 'endereco.endereco',
'options' => ['visible' => 'hidden'],
],
];
echo DynaGrid::widget([
'storage' => 'db',
'columns' => $columns,
'options' => ['id' => 'lista_escritorio_grid'], // um identificador único é importante!
'userSpecific' => false,
'toggleButton' => ['label' => 'Personalizar'],
'theme' => 'panel-primary',
'gridOptions' => [
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'showPageSummary'=> false,
'panel' => [
'heading' => '<h3 class="panel-title">Listas</h3>',
//'after' => '{export}',
],
],
]);
'dynagrid' => [
'class' => 'kartik\dynagrid\Module',
'dbSettings' => [
'tableName' => 'psw_configuracao',
'idAttr' => 'chave',
'dataAttr' => 'valor',
],
'i18n' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@kvdynagrid/messages',
'forceTranslation' => true
],
],
'gridview' => [
'class' => 'kartik\grid\Module',
// other module settings
],
What's wrong?
If I use DynaGrid without filterModel, I get the following message:
PHP Notice – yii\base\ErrorException
Undefined index: filterModel
1. in /home/evgen-d/project/application/vendor/kartik-v/yii2-dynagrid/DynaGrid.php at line 642
/**
* Applies the grid filter
*/
protected function applyFilter()
{
$class = get_class($this->gridOptions['filterModel']);
if (!empty($this->_detailConfig[DynaGridStore::STORE_FILTER]) && empty($_GET[$class])) {
$attributes = $this->_detailConfig[DynaGridStore::STORE_FILTER];
$searchModel = $this->gridOptions['filterModel'];
$searchModel->setAttributes($attributes);
$this->gridOptions['filterModel'] = $searchModel;
$this->initDataProvider($searchModel);
}
}
Suggestion
Add a attribute 'showPersonalize' for example, with true/false to show or no the personalize button (that is where located the configurations grid, visible columns, ...).
It's utilized for user permission level.
Regards
Hi,
can you pls. add a migrate script for the additional needed tables and columns, as many people use migrate functionality to deploy solutions and add them to migrate environment...
Thanks Philipp
it would be nice to deactivate this select2 out of the box
same logic as allowFilterSetting
and allowSortSetting
.
and / or
the ability to set the default views per widget. not only globally
Allow dynagrid to be more extensible - by allowing to change gridoptions at runtime before rendering the grid.
The following code:
<?= DynaGrid::widget([
...
'gridOptions' => [
...
'showPageSummary' => true,
],
]) ?>
generates this HTML output:
<tfoot>
<tr class="kv-page-summary warning">
<td style="width:50px;" class="kv-align-center kv-align-middle"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tfoot>
What's wrong?
You have a bug in getDataFromDb function.
Here is fix: https://github.com/snickom/yii2-dynagrid/commit/64fe472f33e0372250bb6d66b57ca6fa44089d4b
I followed the configuration steps (details later), but I get this error message.
After a successfully composer update I see yii2-dynagrid folder inside kartik-v folder. If I am right there should be a DynaGrid.php file inside kartik-v/widgets folder, but there isn't.
Maybe I forget to config something, but I lost in debuging :(
My config steps were the followings:
I inserted the following into web.php module section.
'dynagrid'=> [
'class'=>'\kartik\dynagrid\Module',
'class'=>'yii\i18n\PhpMessageSource',
'basePath'=>'@kvdynagrid/messages',
'forceTranslation'=>true
],
'gridview'=> [
'class'=>'\kartik\grid\Module',
'class'=>'yii\i18n\PhpMessageSource',
'basePath'=>'@kvdynagrid/messages',
'forceTranslation'=>true
],
In my index.php I added these namespaces
use yii\helpers\ArrayHelper;
use kartik\helpers\Html;
use kartik\grid\GridView;
use kartik\widgets\DynaGrid;
After the $gridColums configuration I called the widget. Not that I get the error message for the first line of the following code.
<?= DynaGrid::widget([
'columns' => $gridColumns,
'storage'=>DynaGrid::TYPE_COOKIE,
'theme'=>'panel-danger',
'gridOptions'=>[
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'gridOptions'=>[
'dataProvider'=>$dataProvider,
'filterModel'=>$searchModel,
'panel'=>['heading'=>'<h3 class="panel-title">Library</h3>'],
]
]
]); ?>
Allow setting pageSize to 0
that will enable display of all records on one page.
I'm always getting this error in chrome console after I search in dynagrid. you can catch it even in you demo page http://demos.krajee.com/dynagrid-demo
Hi,
i tried to "multisort" in your demo. It seems it doesnt work correctly?
i understand multisort as "stable sorted"
http://en.wikipedia.org/wiki/Sorting_algorithm#Stability
or what do you mean with "multisort"?
your extensions are beautiful. what about TO enhance your grid with a relational column like the one in yiiwheels? in this manner we can display a child inside the parent grid. in this grid we can display data from a related table or other hidden data from parent grid.
I think after the last change does not work "before" value in panel into gridOptions.
if change ( into file DynaGrid.php ) $this->gridOptions = ArrayHelper::merge($this->gridOptions, $theme);
to $this->gridOptions = ArrayHelper::merge($theme, $this->gridOptions); works !!
otherwise 'before' cannot displayed
this merge takes 'before' from $theme variant and ignore [panel][before].
probably not working and in your demo.
I get this error when i tried to use dynagrid.
I install dynagrid an yii2 by composer fresh today.
I have other proyect where dynagrid go like a charm and yiie-dev its not up-date.
Can you help- me please?
Hello,
on my application, after post of the configurations (columns, etc...)
the configuration window is not working correctly...
...look the images...
Private variables, alter them to protected.
In my application i have custom configurations and i extend your dynagrid... is not generic, it is specific of my application.
The private variables generate error when extending the class (obviously) so I alter them to protected.
Correct the modal and revert it being positioned at the end of the body so that form is submitted right.
Saved filter and sort deletion is not behaving as expected (deletion needs to occur after refresh of controller).
While grid pjax setting is true and I'm using a select2 within filter, I recieve the following error message:
Uncaught ReferenceError: initSelect2Loading is not defined
Congratulations for the best developed extensions. Have a suggestion, which I believe does not exist: have you thought of adding support for it > http://mistic100.github.io/jQuery-QueryBuilder/ or for it:
Thanks.
Hi 👍
If i want to put more buttons in grid a can use 👍
'panel' => [
'heading'=>'
But in Dynagrid after and before dont work in panel.
Hello, @kartik-v !
If i use ArrayDataProvider as dataProvider - ability to sort by columns is lost.
If i change dataProvider on ActiveDataProvider - columns sorts is fine.
This will minimize conflict of grid related content updates at runtime via javascript.
I'm trying to disable sort and pagination, as documented here: http://www.yiiframework.com/doc-2.0/yii-data-basedataprovider.html#$pagination-detail
If I use a yii2 gridview, this works, in a dynagrid this throws an error. Here is the code:
$SampleSearchModel = new SampleSearch();
$searchparam = ArrayHelper::Merge(Yii::$app->request->queryParams, ['SampleSearch' => ['job_id' => $id]]);
$SampleDataProvider = $SampleSearchModel->search($searchparam);
$SampleDataProvider->pagination = false;
Gives the following error:
Creating default object from empty value
Dynagrid.php line 877: $pagination->pageSize = $this->_pageSize;
The same with sort:
Call to a member function getOrders() on boolean
Dynagrid.php line 999: $model->data = $this->gridOptions['dataProvider']->getSort()->getOrders();
Falls the following error:
PHP Strict Warning – yii\base\ErrorException
Only variables should be passed by reference
1. in /var/www/erp.avalon.kz.dev/vendor/kartik-v/yii2-dynagrid/dynagrid/DynaGrid.php at line 637
We can fix it as follows:
$class = explode('\\', $class);
$label = Inflector::camel2words(end($class));
But then falls a critical error: "502 Bad Gateway". Falls a backend,
I use Debian, nginx + php5-fpm, php55.
The error occurs in the function applyColumns().
Fixed:
if (isset($column['order']) && isset($column['visible'])) {
unset($column['order'], $column['visible']);
}
If necessary, I can make pull request.
Use the new ability of yii2-grid
support for pjax. Enhance extension to autoinitialize all jquery plugins when gridOptions['pjax']
is set to true.
Hello, I need a help.
I would like to:
When the request is comming from ajax, only the modal should be reloaded. is it possible?
How can i do it?
And the new feature (showPersonalize), if set it to false, the export button becomes hidden too..
Is it possible to set the parameter (showPersonalize false), showing the export button only?
I do apologize for the many doubts and suggestions.
Best Regards,
Kartik,
I did the update by getting the code from dev-master but when I put 'allowThemeSetting' => false, than the grid doesn't save my changes that I did on the Personalize Grid Configuration screen.
If I remove allowThemeSetting than it works.
After installation error:
PHP Fatal Error – yii\base\ErrorException
Class 'kartik\sortable\Sortable' not found
In file /vendor/kartik-v/yii2-dynagrid/dynagrid/views/config.php
English is not my mother tongue, otherwise i would create a pull request. I had a problem where some columns where hidden because I had multiple grids on different pages without an ID.
Hi:
I have a message translate to spanish. If you think could be interesant tell me where to upload.
Thanks for a great work.
368369370371372373374375376377378379380 'id' => $this->options['id'],
'storage' => $this->storage,
'userSpecific' => $this->userSpecific
]);
$this->prepareColumns();
$this->configureColumns();
$this->applyGridConfig();
$this->_isPjax = ArrayHelper::getValue($this->gridOptions, 'pjax', false);
if ($this->_isPjax) {
$this->gridOptions['pjaxSettings']['options']['id'] = $this->_pjaxId;
}
$this->initGrid();
Uncaught TypeError: Cannot read property 'selectionColumn' of undefined
Some times we try to minimize the fontsize in case we have lots of columns need to display in grid.
I am using my customized ajax function to dyna adjust fontsize for dynagrid now.
Would suggest you direct provoide this function for dynagrid widget.
Such as a dropdown list allow user to select huge/large/normal/small/tiny(140%/120%/100%/85%/70%) fontsize and then dynagrid change its all fontsize style immediately with ajax.
With this enhancement, one can set the sort
and pagination
to false
for the gridOptions['dataProvider']
- to entirely disable them.
New boolean property allowPageSetting
that will allow you to display the pagination widget if needed. If pagination
is set to false
this will be automatically set to false
.
I suggest changing the default grid personalization configuration dialog box to make the column settings section part consisting of a single column of all field names with check boxes beside each field to show/hide it instead of two columns and the drag and drop for sorting them. This would make it more touch-friendly and more intuitive. It would be also better for touch devices if the sorting could be done by up/down buttons in each field element.
Probably also move the whole column settings section form the current dialog box to a drop down menu or separate dialog box popping from a button in the panel area and move the number of rows setting to a drop down list with fixed settings in the panel, and add a drop down list for filters.
This would make the grid more readily usable out of the box.
Kartik,
Sorry to open an issue for this but I'm trying for almost month already and with no success.
I need to get the selected rows (checkbox) so I can export or do whatever I can do with all the selected rows.
Can you help me please?
I suggest adding Model as a storage option to the current ones. The developer would pass models inhered from DynaGridConfig and DynaGridSettings. My understanding is that there's currently no direct way to interrupt the above models' data moved from/to the grid and the database to perform any extra processing. For example, to filter the retrieved user column set against a permissions list set by the admin as those permission could be updated after the user settings were saved, so the user does not see columns/data he's no longer supposed to see. There are also other useful uses for this.
When multiple grids are present on a site, and the preferences on one grid is changed. It will change the preferences for the other grids (seems to be only one cookie)
This becomes problematic when you are customizing the columns on one grid, it will try to change columns on other grids.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.