Download the PHP package uestla/twigrid without Composer
On this page you can find all versions of the php package uestla/twigrid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download uestla/twigrid
More information about uestla/twigrid
Files in uestla/twigrid
Package twigrid
Short Description Experimental DataGrid for Nette Framework
License MIT
Homepage https://github.com/uestla/TwiGrid
Informations about the package twigrid
TwiGrid
... is a DataGrid for Nette Framework.
Demo: https://kesspess.cz/twigrid/
Demo sources: https://github.com/uestla/twigrid-demo
It's based on another (and great) datagrid written by @hrach - https://github.com/nextras/datagrid. My datagrid is hugely inspired by this component and its programming ideas and therefore I would like to give this man a maximum credit and respect :-)
Quickstart
Let's see how many steps do we have to make to create our first datagrid.
-
Create new project
-
Install TwiGrid & client-side assets
If you're not using yarn, you can install assets manually by looking into
package.json
and see required dependencies there.We'll then update
app/Presenters/templates/@layout.latte
to load downloaded assets: -
Database
Download the SQLite3 file from the demo application and place it in
app/Model/users.s3db
.And we'll configure this database to be used by the application:
-
Create datagrid
Now it's finally time to create our first datagrid - let's create an
app/Grids/UsersGrid.php
file. We'll need database connection for data loading, so we inject it properly via constructor.We'll define the datagrid body inside the
build()
method. Although the tableuser
has many columns, we'll have just some of them in our grid just to make it easy.TwiGrid also needs to know what column(s) it should consider as a primary key:
And finally we'll tell TwiGrid how to load our users:
-
To properly inject our grid into presenters, we'll need to create a factory interface:
This interface will now be used for automatic factory generation, which is handy - we simply add this definition to
config/common.neon
: -
Having all of this done, we can now simply inject our grid factory into
HomepagePresenter
.Now we'll add the control factory itself:
-
We're nearly done! Just open
app/Presenters/templates/Homepage/default.latte
, delete the whole content and replace it withThat's all, folks!
Now when you'll open the page, you might see something like this:
-
Final improvement
Maybe showing the country code isn't that sexy - we'd like to have the whole country name in "Country" column. To achieve that, we'll create custom grid template:
And tell TwiGrid to use this template:
Simple as that!
More
To see more examples, please visit the demo page. Enjoy!
All versions of twigrid with dependencies
nette/http Version ^3.0
nette/forms Version ^3.0
nette/utils Version ^3.0 || ^4.0
latte/latte Version ^2.5 || ^3.0
nette/application Version ^3.0