Krajee

GridView Demo

Thankful to Krajee! BUY A COFFEEor to get more out of us.

Note

This is an advanced usage of the ExpandRowColumn for the kartik\grid\GridView widget. It shows how to initialize selectively few of the rows as EXPANDED. It also uses the AJAX mode of rendering content in this demo (which is set via the detailUrl property). You can check the grid configuration code below the demo as well as click the to view the $gridColumns configuration code. You can configure the appearance and behavior of the widget. View this complete web tip on how to setup your model, controller, and view with GridView Editable columns to manipulate records.

For grid grouping demos click here — For advanced ExpandRowColumn usage demo click here

Tip

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)

Showing 1-10 of 20 books.
Library
* Resize table columns just like a spreadsheet by dragging the column edges.
 
NameColorAuthorBuy Amount ($)Sell Amount ($)Buy + Sell
(BS)
Buy %
(100 * B/BS)
StatusActions
1
   blueF. Scott Fitzgerald
300.00509.0058.94Active
2
   redJohn Steinbeck
155.50259.5059.92Active
3
   orangeGeorge Orwell
98.50177.5055.49Active
4
Ulysses   greenJames Joyce69.0098.50167.5058.81Inactive
5
   pinkVladimir Nabokov
85.50143.5059.58Active
6
   cyanJoseph Heller
105.50190.5055.38Active
7
   redJ. D. Salinger
125.50230.5054.45Active
8
Beloved   greenToni Morrison130.00154.99284.9954.38Inactive
9
   brownWilliam Faulkner
125.50231.5054.21Active
10
To Kill a Mockingbird    orangeHarper Lee79.0098.50177.5055.49Inactive
Total1,024.001,347.992,371.9956.67(amounts in $)
* The page summary displays SUM for first 3 amount columns and AVG for the last.

Configure GridView


Table Setting
Panel Setting  


           
Panel Content


The GridView Configuration

  1. echo GridView::widget([
  2. 'id' => 'kv-grid-demo',
  3. 'dataProvider' => $dataProvider,
  4. 'filterModel' => $searchModel,
  5. 'columns' => $gridColumns, // check this value by clicking GRID COLUMNS SETUP button at top of the page
  6. 'headerContainer' => ['style' => 'top:50px', 'class' => 'kv-table-header'], // offset from top
  7. 'floatHeader' => true, // table header floats when you scroll
  8. 'floatPageSummary' => true, // table page summary floats when you scroll
  9. 'floatFooter' => false, // disable floating of table footer
  10. 'pjax' => false, // pjax is set to always false for this demo
  11. // parameters from the demo form
  12. 'responsive' => false,
  13. 'bordered' => true,
  14. 'striped' => false,
  15. 'condensed' => true,
  16. 'hover' => true,
  17. 'showPageSummary' => true,
  18. 'panel' => [
  19. 'after' => '<div class="float-right float-end"><button type="button" class="btn btn-primary" onclick="var keys = $("#kv-grid-demo").yiiGridView("getSelectedRows").length; alert(keys > 0 ? "Downloaded " + keys + " selected books to your account." : "No rows selected for download.");"><i class="fas fa-download"></i> Download Selected</button></div><div style="padding-top: 5px;"><em>* The page summary displays SUM for first 3 amount columns and AVG for the last.</em></div><div class="clearfix"></div>',
  20. 'heading' => '<i class="fas fa-book"></i> Library',
  21. 'type' => 'primary',
  22. 'before' => '<div style="padding-top: 7px;"><em>* Resize table columns just like a spreadsheet by dragging the column edges.</em></div>',
  23. ],
  24. // set export properties
  25. 'export' => [
  26. 'fontAwesome' => true
  27. ],
  28. 'exportConfig' => [
  29. 'html' => [],
  30. 'csv' => [],
  31. 'txt' => [],
  32. 'xls' => [],
  33. 'pdf' => [],
  34. 'json' => [],
  35. ],
  36. // set your toolbar
  37. 'toolbar' => [
  38. [
  39. 'content' =>
  40. Html::button('<i class="fas fa-plus"></i>', [
  41. 'class' => 'btn btn-success',
  42. 'title' => Yii::t('kvgrid', 'Add Book'),
  43. 'onclick' => 'alert("This should launch the book creation form.\n\nDisabled for this demo!");'
  44. ]) . ' '.
  45. Html::a('<i class="fas fa-redo"></i>', ['grid-demo'], [
  46. 'class' => 'btn btn-outline-secondary',
  47. 'title'=>Yii::t('kvgrid', 'Reset Grid'),
  48. 'data-pjax' => 0,
  49. ]),
  50. 'options' => ['class' => 'btn-group mr-2 me-2']
  51. ],
  52. '{export}',
  53. '{toggleData}',
  54. ],
  55. 'toggleDataContainer' => ['class' => 'btn-group mr-2 me-2'],
  56. 'persistResize' => false,
  57. 'toggleDataOptions' => ['minCount' => 10],
  58. 'itemLabelSingle' => 'book',
  59. 'itemLabelPlural' => 'books'
  60. ]);

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.

 
4,689,845 visitors to Krajee Yii2 Demos since 22-May-2017
cancel
cancel
cancel
cancel
cancel
cancel
cancel
cancel