Grids 4.9



Maintainers
Details
  • When the grid voltage reaches 4.9 V, electron collisions near the grid become inelastic, and the electrons are greatly slowed. The kinetic energy of a typical electron arriving at the grid is reduced so much that it cannot travel further to reach the anode, whose voltage is set to slightly repel electrons.
  • Grid Gallery uses a brand new algorithm to make much more interesting image grids, how does it work? The main concept is very simple: it doesn’t have any lightbox, because in grid gallery images open without lightbox like a slider, it means it’s working like a slider but it looks like a gallery.

Data Grids Framework for Laravel. Laravel 4.X, Laravel 5.X and Laravel 6 are supported. Pull-requests from 3rd-party contributors containing new features can be accepted to nayjest/grids just in case when it doesn't break backward compatibility. If you have some radical improvements, please contribute to view-components/grids. Grid object or null if the operation failed. If the image represents a visualization proxy for grid, than the grid datasource will be opened, otherwise the datasource of image itself. New API 4.9.1: Added in.

Installs: 89 672

Dependents: 4

Suggesters: 1

Security: 0

Grid 4.3.4 wow

Stars: 197

Watchers: 18

Forks: 79

Open Issues: 51

Requires

  • php: >=5.4.0
  • illuminate/support: >=4.2
  • nayjest/builder: ~2

Suggests

  • laravelcollective/html: Required to work with Laravel 5.X
  • maatwebsite/excel: Required to work with Excel export component

Provides

None

Conflicts

None

This package is auto-updated.

Last update: 2021-04-16 15:00:37 UTC

Data Grids Framework for Laravel

Laravel 4.X, Laravel 5.X and Laravel 6 are supported.

  • Pull-requests from 3rd-party contributors containing new features can be accepted to nayjest/grids just in case when it doesn't break backward compatibility. If you have some radical improvements, please contribute to view-components/grids.

Features

  • Data providers (php array, Eloquent model, Doctrine DBAL query object)
  • Themes support
  • Individual views for UI components
  • Twitter Bootstrap v3 used by default
  • Caching
  • Smart input handling allows to avoid conflicts with get parameters & easily place few interactive grids on same page
  • Rich customization facilities
  • Component architecture
  • Declarative approach
  • Constructing grids via strict object oriented API or configuration in php arrays
  • Rich variety of components:
    • Excel and CSV export
    • Records per page dropdown
    • Show/hide columns UI control
    • Sorting
    • Filtering
    • Totals calculation (sum, average value, records count, etc)
    • Pagination
    • etc

Upcoming Features (moved to view-components/grids)

  • Autodetecting columns based on Eloquent model (if not specified)
  • Builtin output formatters for different column types
  • Working with json data sources via ajax
  • Check compatibility with Lumen microframework

Requirements

  • Laravel 4.X / 5.X / 6.X
  • laravelcollective/html package if you use Laravel5.X
  • php 5.4+

Installation

Step 1: Install package using Composer

Add nayjest/grids to 'require' section of your composer.json

For Laravel 5 you also need to add 'laravelcollective/html':

4.9

Then install dependencies using following command:

Instead of editing composer.json and executing composer install you can just run following command:

For Laravel 4

For Laravel 5 / Laravel 6

Step 2: Laravel Setup

Add following line to 'providers' section of app/config/app.php file:

For Laravel 5 / 6 you also need to add 'illuminate/html' service provider:

You may also add facade aliases to your application configuration:

Demo

Demonstration available here

Usage

Basic example

In example below grid is configured by php array using Nayjest/Builder package facilities.

Results available here. For more details see demo application repository

Advanced example

If you don't like plain arrays, you can construct grids using object oriented api:

Step 1. Instantiate & Configure Grid

See example below

Step 2. Render Grid

Notes

  • Class names in example code used without namespaces therefore you must import it before
  • Grids does not includes Twitter Bootstrap css/js files to your layout. You need to do it manuallyQuick links:
  • NayjestGridsComponentsPager component works only with Laravel 4.X, for Laravel 5 / 6 use NayjestGridsComponentsLaravel5Pager
Working with related Eloquent models

If you need to render data from related Eloquent models, the recommendation is to use joinsinstead of fetching data from related models becouse in this case filters/sorting will not work.Grids sorting and filters changes Laravel query object, but Laravel makes additional queries to get data for related models, so it's impossible to use filters/sorting with related models.

Following example demonstrates, how to construct grid that displays data from Customer model and related Country model.

Upgrade Guide

From 1.X to 2.X

There are full backward compatibility between 1.X and 2.X branches.

From 0.9.X to 1.X

There are full backward compatibility between 0.9.X and 1.X branches.

From 0.8.X to 0.9.X

Grids starting from v 0.9.0 uses 'laravelcollectivehtml' instead of outdated 'illuminatehtml'.

You may continue to use illuminatehtml, but it's recommended to replace it to laravelcollectivehtml.

  1. Replace illuminatehtml to laravelcollectivehtml in composer.json

  2. Replace class aliases section in config/app.php ('IlluminateHtmlHtmlFacade' to 'CollectiveHtmlFormFacade' and 'IlluminateHtmlHtmlFacade' to 'CollectiveHtmlHtmlFacade')

  3. Replace 'IlluminateHtmlHtmlServiceProvider' to 'CollectiveHtmlHtmlServiceProvider'

  4. Run composer update

From 0.3.X to 0.4.X

  1. Use THead & TFoot instead of Header & Footer components
  2. If you have customized grid view (grid.php), refactor it using changes in default view
  3. Some components became default, so you don't need to add it to configuration

Default components hierarchy:

For adding child components to default one, resolve it by name and use addComponent / addComponents methods.

Example:

Note that setComponents method rewrites components structure provided by defaults.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email mail@vitaliy.in instead of using the issue tracker.

License

© 2014—2019 Vitalii Stepanenko

Licensed under the MIT License.

Please see License File for more information.

Functions

bool Image._pushSchemetkRaster (GridColorScheme cScheme)
Sets color scheme to use in process of generation of the image representation of the grid. More...
GridImage.OpenAsGrid ()
Opens the datasource of the image as grid. More...

Properties

tkGridRendering Image.AllowGridRendering [get, set]
Gets or sets the value which indicates whether the image will be rendered as grid, i.e. with a color scheme applied to a band set by Image.SourceGridBandIndex. More...
bool Image.AllowHillshade [get, set]
Indicate whether hillshade algorithm will be used for generation of image representation of the grid. More...
GridColorSchemeImage.CustomColorScheme [get, set]
Gets or sets the color scheme to render image with. More...
GridColorSchemeImage.GridProxyColorScheme [get]
Gets grid color scheme this proxy image was generated with. The method should be called for proxy images only: Image.IsGridProxy = true. More...
bool Image.GridRendering [get]
Returns true if the image is rendered as grid. More...
PredefinedColorSchemeImage.ImageColorScheme [get, set]
Gets or sets the predefined color scheme for the image. Applicable for GDAL images only. More...
bool Image.IsGridProxy [get]
Gets the value which indicates whether an image object represents a visualization proxy for another datasource. More...
int Image.SourceGridBandIndex [get, set]
Gets or sets index of band within datasource whose values should be used to apply color scheme. More...
string Image.SourceGridName [get]
Gets the name of the source grid in case the image represent a visualization proxy for a grid. More...

Detailed Description

Here is a list of properties and methods that affects rendering of grids. The properties and methods described here belong to Image class.

Graph description
Working with grid data.
Image class can be used for rendering grid data. Grid datasources can be rendered in 2 ways:

  • direct rendering using GDAL drivers (see grid rendering section below);
  • rendering using proxy image.

In both cases the name of the original datasource is stored in Image.SourceGridName property. Source grid can be opened using Image.OpenAsGrid. No interpolation is usually used during rendering of grid datasources since it's often desirable to see borders of individual pixels (see Image.UpsamplingMode, Image.DownsamplingMode). More details on grids see of Grid class.
1. Grid rendering.
Any GDAL-based image can be displayed using so called grid rendering, i.e. not by using it's own colors but by mapping the values of one of its bands to new set of colors. Grid rendering is used depending on datasource type:

  • for grid datasources it's the only one available since no colors are stored in datasource itself;
  • for regular RGB images the usage can be turned on/off with Image.AllowGridRendering property; grid rendering in this case actually is nothing more than the usage of synthetic colors to display on of the original color bands.

Image.IsRgb property can be used to determine whether the current datasource is grid or RGB image. The rendering method can be returned by Image.GridRendering property. Grid rendering always applies to a single band specified by Image.SourceGridBandIndex.
Color scheme for grid rendering can be set using:

  • Image.CustomColorScheme property (or an older alternative Image._pushSchemetkRaster method);
  • Image.ImageColorScheme property (will be used when no custom color scheme was set);

Forcing grid rendering for RGB image:

var img = newImage();
if (img.Open(filename, ImageType.USE_FILE_EXTENSION, true, null))
if (img.IsRgb)
img.AllowGridRendering = tkGridRendering.grForceForAllFormats;
img.ImageColorScheme = PredefinedColorScheme.SummerMountains;
img.SourceGridBandIndex = 2; // let's choose second band
Debug.Print('Image is rendered as grid: ' + img.GridRendering);
}

Setting custom unique values color scheme for directly rendered grid:

var img = newImage();
if (img.Open(filename, ImageType.USE_FILE_EXTENSION, true, null))
if (!img.IsRgb)
var grid = img.OpenAsGrid();
{
var scheme = grid.GenerateColorScheme(tkGridSchemeGeneration.gsgUniqueValues, PredefinedColorScheme.FallLeaves);
grid.Close();
Debug.Print('Image is rendered as grid: ' + img.GridRendering);
}

Setting default color scheme for directly rendered grid:

var img = newImage();
if (img.Open(filename, ImageType.USE_FILE_EXTENSION, true, null))
if (!img.IsRgb)
img.ImageColorScheme = PredefinedColorScheme.Glaciers;
img.CustomColorScheme = null; // make sure that there is no custom color scheme to override out setting
}

2. Proxy images for grids.
Proxy image is regular RGB image file created for rendering a grid. It can have BMP or GTiff format and name of the grid + '_proxy' postfix (see details on their creation in Grid class). The rendering of proxy image has no differences compared to any other RGB image. Additional responsibilities of Image class in this case include:

  • identification of proxy image on opening;
  • providing diagnostic properties for user, so that original grid can be accessed.

It's implemented like this:

  • Image.Open method will analyze filename for '_proxy' suffix and then will try to find .mwleg color scheme file for it;
  • if such file exists, the name of the source grid will be read from it and set to Image.SourceGridName property;
  • Image.IsGridProxy property will be set to true.

The source grid can be accessed using Image.OpenAsGrid method.
Here is an examples which demonstrate changing of format for proxy image already added to the map from BMP to GTiff (it's not very practical example, but good demonstration of API):

var img = axMap1.get_Image(layerHandle);
if (img.IsGridProxy && img.SourceType != tkImageSourceType.istGDALBased)
var grid = img.OpenAsGrid();
{
var scheme = img.GridProxyColorScheme; // we shall use the same color scheme
axMap1.RemoveLayer(layerHandle); // removing original proxy
var gs = newGlobalSettings();
gs.GridProxyFormat = tkGridProxyFormat.gpfTiffProxy; // new one must be GTiff
var newImage = grid.CreateImageProxy(scheme);
{
}
}

Function Documentation

_pushSchemetkRaster()

bool Image._pushSchemetkRaster (GridColorSchemecScheme)

Sets color scheme to use in process of generation of the image representation of the grid.

Parameters
cSchemeThe color scheme.
Returns
True on success and false otherwise.

OpenAsGrid()

Opens the datasource of the image as grid.

Returns
Grid object or null if the operation failed.

If the image represents a visualization proxy for grid, than the grid datasource will be opened, otherwise the datasource of image itself.

New API 4.9.1:
Added in version 4.9.1

Properties

AllowGridRendering

Gets or sets the value which indicates whether the image will be rendered as grid, i.e. with a color scheme applied to a band set by Image.SourceGridBandIndex.

New API 4.9.1:
Added in version 4.9.1

AllowHillshade

Grids 4.9 Free

Indicate whether hillshade algorithm will be used for generation of image representation of the grid.

The behaviour has changed in v4.9. Now when active it only switches ColoringType from Hillshade to Gradient. In v.4.8. it used to have the same behaviour as Image.AllowExternalColorScheme.

CustomColorScheme

Gets or sets the color scheme to render image with.

This property should be used for grid datasources in the first place (when there is no build-in colors). But may also be used for a single band of regular RGB/ARGB images for synthetic colors and hillshading. When no custom color scheme is set, grid rendering is chosen the color scheme from Image.ImageColorScheme will be used.

New API 4.9.1:
Added in version 4.9.1

GridProxyColorScheme

Gets grid color scheme this proxy image was generated with. The method should be called for proxy images only: Image.IsGridProxy = true.

Color scheme will be read from .mwleg XML file on the disk.

GridRendering

Returns true if the image is rendered as grid.

New API 4.9.1:
Added in version 4.9.1

ImageColorScheme

PredefinedColorScheme Image.ImageColorScheme
getset

Grids 4.9 License Key

Gets or sets the predefined color scheme for the image. Applicable for GDAL images only.

The color scheme is used for generation of image representation of the grid.

IsGridProxy

Gets the value which indicates whether an image object represents a visualization proxy for another datasource.

Will return true if the image was opened with Grid.OpenAsImage only. When opened directly the link to the source grid will be lost.

New API 4.9.1:
Added in version 4.9.1

SourceGridBandIndex

Gets or sets index of band within datasource whose values should be used to apply color scheme.

Other bands will ignored during display process. This is useful for multiband grids (e.g. NetCDF), but may also be used with RGB images, to set synthetic colors for a single band.

New API 4.9.1:
Added in version 4.9.1

SourceGridName

Gets the name of the source grid in case the image represent a visualization proxy for a grid.

New API 4.9.0:
Added in version 4.9.0