session
for the demo). Pjax is enabled for the grid for the demo. You can refer the
use kartik\dynagrid\DynaGrid; $columns = [ ['class'=>'kartik\grid\SerialColumn', 'order'=>DynaGrid::ORDER_FIX_LEFT], [ 'attribute'=>'name', 'pageSummary'=>'Page Total', 'vAlign'=>'middle', 'order'=>DynaGrid::ORDER_FIX_LEFT ], [ '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, 'filterWidgetOptions'=>[ 'showDefaultPalette'=>false, 'pluginOptions'=>[ 'showPalette'=>true, 'showPaletteOnly'=>true, 'showSelectionPalette'=>true, 'showAlpha'=>false, 'allowEmpty'=>false, 'preferredFormat'=>'name', 'palette'=>[ [ "white", "black", "grey", "silver", "gold", "brown", ], [ "red", "orange", "yellow", "indigo", "maroon", "pink" ], [ "blue", "green", "violet", "cyan", "magenta", "purple", ], ] ], ], 'vAlign'=>'middle', 'format'=>'raw', 'width'=>'150px', 'noWrap'=>true ], [ 'attribute'=>'publish_date', 'filterType'=>GridView::FILTER_DATE, 'format'=>'raw', 'width'=>'170px', 'filterWidgetOptions'=>[ 'pluginOptions'=>['format'=>'yyyy-mm-dd'] ], 'visible'=>false, ], [ 'attribute'=>'author_id', 'vAlign'=>'middle', 'width'=>'250px', 'value'=>function ($model, $key, $index, $widget) { return Html::a($model->author->name, '#', [ 'title'=>'View author detail', 'onclick'=>'alert("This will open the author page.\n\nDisabled for this demo!")' ]); }, 'filterType'=>GridView::FILTER_SELECT2, 'filter'=>ArrayHelper::map(Author::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions'=>[ 'pluginOptions'=>['allowClear'=>true], ], 'filterInputOptions'=>['placeholder'=>'Any author'], 'format'=>'raw' ], [ 'attribute'=>'buy_amount', 'hAlign'=>'right', 'vAlign'=>'middle', 'width'=>'100px', 'format'=>['decimal', 2], 'pageSummary'=>true ], [ 'attribute'=>'sell_amount', 'vAlign'=>'middle', 'hAlign'=>'right', 'width'=>'100px', 'format'=>['decimal', 2], 'pageSummary'=>true ], [ 'class'=>'kartik\grid\BooleanColumn', 'attribute'=>'status', 'vAlign'=>'middle', ], [ 'class'=>'kartik\grid\ActionColumn', 'dropdown'=>false, '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'], 'order'=>DynaGrid::ORDER_FIX_RIGHT ], ['class'=>'kartik\grid\CheckboxColumn', 'order'=>DynaGrid::ORDER_FIX_RIGHT], ]; $dynagrid = DynaGrid::begin([ 'columns' => $columns, 'theme'=>'panel-info', 'showPersonalize'=>true, 'storage' => 'session', 'gridOptions'=>[ 'dataProvider'=>$dataProvider, 'filterModel'=>$searchModel, 'showPageSummary'=>true, 'responsive' => false, 'responsiveWrap'=>false, 'floatHeader'=>true, 'headerContainer' => ['class' => 'kv-table-header', 'style' => 'top: 50px'], 'pjax'=>true, 'panel'=>[ 'heading'=>'<h3 class="panel-title"><i class="fas fa-book"></i> Library</h3>', 'before' => '<div style="padding-top: 7px;"><em>* The table header sticks to the top in this demo as you scroll</em></div>', 'after' => false ], 'toolbar' => [ ['content'=> Html::button('<i class="fas fa-plus"></i>', ['type'=>'button', 'title'=>'Add Book', 'class'=>'btn btn-success', 'onclick'=>'alert("This will launch the book creation form.\n\nDisabled for this demo!");']) . ' '. Html::a('<i class="fas fa-repeat"></i>', ['dynagrid-demo'], ['data-pjax'=>0, 'class' => 'btn btn-outline-secondary', 'title'=>'Reset Grid']) ], ['content'=>'{dynagridFilter}{dynagridSort}{dynagrid}'], '{export}', ] ], 'options'=>['id'=>'dynagrid-1'] // a unique identifier is important ]); if (substr($dynagrid->theme, 0, 6) == 'simple') { $dynagrid->gridOptions['panel'] = false; } DynaGrid::end();
visible
property to false
.
Also check certain columns being fixed to the left and right in the setup.
Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)
# | Name | Color | Author | Buy Amount ($) | Sell Amount ($) | Status | Actions | |
---|---|---|---|---|---|---|---|---|
| ||||||||
11 | The Lord of the Rings | purple | J. R. R. Tolkien | 109.00 | 158.50 | Active | ||
12 | One Hundred Years of Solitude | yellow | Gabriel García Márquez | 165.00 | 195.50 | Active | ||
13 | Brave New World | blue | Aldous Huxley | 115.00 | 175.50 | Active | ||
14 | To the Lighthouse | pink | Virginia Woolf | 105.00 | 145.50 | Active | ||
15 | Invisible Man | cyan | Ralph Ellison | 105.00 | 165.50 | Active | ||
16 | Gone with the Wind | brown | Margaret Mitchell | 123.00 | 185.50 | Active | ||
17 | Jane Eyre | black | Charlotte Brontë | 140.00 | 195.50 | Active | ||
18 | On the Road | orange | Jack Kerouac | 150.00 | 184.99 | Inactive | ||
19 | Pride and Prejudice | green | Jane Austen | 126.00 | 195.50 | Active | ||
20 | Lord of the Flies | red | William Golding | 169.00 | 188.50 | Active | ||
Page Total | 1,307.00 | 1,790.49 |
Comments & Discussion
Note
You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.
The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.