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 | |
---|---|---|---|---|---|---|---|---|
| ||||||||
1 | The Great Gatsby | blue | F. Scott Fitzgerald | 209.00 | 300.00 | Active | ||
2 | The Grapes of Wrath | red | John Steinbeck | 104.00 | 155.50 | Active | ||
3 | Nineteen Eighty-Four | orange | George Orwell | 79.00 | 98.50 | Active | ||
4 | Ulysses | green | James Joyce | 69.00 | 98.50 | Inactive | ||
5 | Lolita | pink | Vladimir Nabokov | 58.00 | 85.50 | Active | ||
6 | Catch-22 | cyan | Joseph Heller | 85.00 | 105.50 | Active | ||
7 | The Catcher in the Rye | red | J. D. Salinger | 105.00 | 125.50 | Active | ||
8 | Beloved | green | Toni Morrison | 130.00 | 154.99 | Inactive | ||
9 | The Sound and the Fury | brown | William Faulkner | 106.00 | 125.50 | Active | ||
10 | To Kill a Mockingbird | orange | Harper Lee | 79.00 | 98.50 | Inactive | ||
Page Total | 1,024.00 | 1,347.99 |
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.