class Grid

Traits

Properties

protected string $name

Grid name.

from  HasElementNames
protected array $elementNames

HTML element names.

from  HasElementNames
protected string $exporter

Export driver.

from  HasExport
protected Filter $filter from  HasFilter
static string $searchKey from  HasQuickSearch
$search from  HasQuickSearch
protected Collection $columns

Collection of all grid columns.

Tools $tools from  HasQuickSearch
protected array $totalRowColumns from  HasTotalRow
protected Closure $actionsCallback

Callback for grid actions.

from  HasActions
protected string $actionsClass

Actions column display class.

from  HasActions
protected array $batchActions from  HasActions
protected Selector $selector from  HasSelector
array $hiddenColumns

Default columns be hidden.

from  CanHidesColumns
protected array $layElem from  LayDefines
protected $layCols from  LayDefines
protected int $layCellMinWidth

全局定义常规单元格的最小宽度,layui 2.2.1 新增

from  LayDefines
protected $layPage from  LayDefines
protected $quickButtons from  HasQuickButton
array $columnNames

All column names of the grid.

array $perPages

Per-page options.

int $perPage 默认分页数
string $tableId
protected LengthAwarePaginator $paginator
protected Model $model

The grid data model instance.

protected Collection $rows

Collection of all data rows.

protected Closure $rowsCallback

Rows callable function.

protected Closure $builder

Grid builder.

protected bool $isBuild

Mark if the grid is builded.

protected array $variables

All variables in grid view.

protected string $keyName

Default primary key name.

protected string $view

View for grid to render.

protected $renderingCallbacks
protected array $options

Options for grid.

static protected $initCallbacks

Initialization closure array.

Methods

$this
setName(string $name)

Set name to grid.

string
getName()

Get name of grid.

string
getGridRowName()

No description

string
getSelectAllName()

No description

string
getPerPageName()

No description

string
getGridBatchName()

No description

string
getExportSelectedName()

No description

string
getSelectedRowsName()

No description

string
elementNameWithPrefix($name)

No description

bool
isShowExporter()

是否显示导出按钮

disableExporter(bool $disable = true)

Disable export.

string
renderExportButton()

Render export button.

exporter($exporter)

Set exporter driver for Grid to export.

string
getExportUrl(int $scope = 1, null $args = null)

Get the export url.

handleExportRequest(bool $forceExport = false)

Handle export request.

getExporter(string $scope)

No description

getFilter()

获取筛选

array|Collection|mixed
applyFilter(bool $toArray = true)

执行查询器

filter(Closure $callback)

Set the grid filter.

Factory|View|string
renderFilter()

Render the grid filter.

$this
initFilter()

初始化筛选

quickSearch($search = null)

No description

mixed|void
applyQuickSearch()

Apply the search query to the query.

addWhereBindings(string $query)

Add where bindings.

array
parseQueryBindings(array $queries)

Parse quick query bindings.

addWhereLikeBinding(string $column, bool $or, string $pattern)

Add where like binding to model query.

addWhereDatetimeBinding(string $column, bool $or, string $function, string $value)

Add where date time function binding to model query.

addWhereInBinding(string $column, bool $or, bool $not, string $values)

Add where in binding to the model query.

addWhereBetweenBinding(string $column, bool $or, string $start, string $end)

Add where between binding to the model query.

addWhereBasicBinding(string $column, bool $or, string $operator, string $value)

Add where basic binding to the model query.

void
tools(Closure $callback)

Setup grid tools.

from  HasTools
string
renderHeaderTools()

Render custom tools.

from  HasTools
initTools(Grid $grid)

Setup grid tools.

from  HasTools
$this
addTotalRow(string $column, Closure $callback)

No description

Factory|View|string
renderTotalRow($columns = null)

No description

$this
actions(Closure|string $actions)

Set grid action callback.

string
getActionClass()

Get action display class.

$this
setActionClass(string $actionClass)

No description

batchActions(array $array)

Set grid batch-action callback.

Grid|mixed
disableBatchActions(bool $disable = true)

No description

string
renderBatchActions()

Render create button for grid.

string
skeletonBatchActions()

Render create button for grid.

$this
selector(Closure $closure)

No description

Factory|View|string
renderSelector()

Render grid selector.

$this
applySelectorQuery()

Apply selector query to grid model query.

bool
disableColumnSelector(bool $disable = true)

Remove column selector on grid.

bool
showColumnSelector()

No description

hideColumns(array|string $columns)

Setting default shown columns on grid.

Collection
visibleColumns()

Get all visible column instances.

array
visibleColumnNames()

Get all visible column names.

array
getDefaultVisibleColumnNames()

Get default visible column names.

array
getVisibleColumnsFromQuery()

Get visible columns from request query.

AuthManager
pyAuth()

get auth

pyTranslator()

get translator

Repository
pyConfig()

Get configuration instance.

DatabaseManager
pyDb()

get db

Kernel
pyConsole()

Get console instance.

Container
pyContainer()

Get IoC Container.

Mailer
pyMailer()

Get mailer instance.

SessionManager|Store
pySession()

Get session instance.

Request
pyRequest()

get request

Redirector
pyRedirector()

get redirector

Factory
pyValidation()

get validation

Dispatcher
pyEvent()

get event

LoggerInterface
pyLogger()

get logger

ResponseFactory
pyResponse()

get response

Filesystem
pyFile()

get file

UrlGenerator
pyUrl()

get url

mixed
pyCache(string $tag = '')

get cache

RedisManager
pyRedis()

get redis

Factory
pyView()

get view

pyPoppy()

get poppy

Ini
pyIni()

Ini Parser

Xml
pyXml()

Ini Parser

pyYaml()

Yaml Parser

layPrependRowSelectorColumn()

增加行选择器

layFormat()

Layui 格式化

layColumns()

列样式

false|string
layDefine()

定义 Layui 的数据定义

array
appendQuickButton(array $buttons)

Get create url.

string
renderQuickButton()

Render create button for grid.

array
skeletonQuickButton()

No description

__construct(Model $model, Closure $builder = null)

Create a new grid instance.

model()

Get Grid model.

setLists(string $grid_class, string $field = '', string $order = 'desc')

No description

$this|mixed
option(string $key, mixed $value = null)

Get or set option for grid.

string
getKeyName()

Get primary key name of model.

void
paginate(int $perPage = 15)

Paginate the grid.

mixed
paginator()

Get the grid paginator.

perPages(array $perPages)

设置分页的可选条目数

disableRowSelector(bool $disable = true)

Disable row selector.

void
build()

Build the grid.

rows(Closure $callable = null)

Set grid row callback function.

string
resource()

Get current resource url.

with(array $variables = [])

Add variables to grid view.

setView(string $view, array $variables = [])

Set a view to render.

setTitle(string $title)

Set grid title.

rendering(callable $callback)

Set rendering callback.

string
render()

Get the string contents of the grid view.

int
getPerPage()

No description

skeleton()

No description

static 
init(Closure $callback = null)

Initialize with user pre-defined default disables and exporter, etc.

initialize()

Initialize.

callInitCallbacks()

Call the initialization closure array in sequence.

void
prependRowSelectorColumn()

添加多选框列

void
applyColumnFilter()

Apply column filter to grid query.

void
applyColumnSearch()

Apply column search to grid query.

array|Collection|mixed
applyQuery()

No description

void
addDefaultColumns()

添加多选 / 操作项目

void
buildRows(array $data)

Build the grid rows.

array
variables()

Get all variables will used in grid view.

void
callRenderingCallback()

Call callbacks before render.

Details

in HasElementNames at line 35
$this setName(string $name)

Set name to grid.

Parameters

string $name

Return Value

$this

in HasElementNames at line 51
string getName()

Get name of grid.

Return Value

string

in HasElementNames at line 59
string getGridRowName()

No description

Return Value

string

in HasElementNames at line 67
string getSelectAllName()

No description

Return Value

string

in HasElementNames at line 75
string getPerPageName()

No description

Return Value

string

in HasElementNames at line 83
string getGridBatchName()

No description

Return Value

string

in HasElementNames at line 91
string getExportSelectedName()

No description

Return Value

string

in HasElementNames at line 99
string getSelectedRowsName()

No description

Return Value

string

in HasElementNames at line 113
protected string elementNameWithPrefix($name)

No description

Parameters

$name

Return Value

string

in HasExport at line 23
bool isShowExporter()

是否显示导出按钮

Return Value

bool

in HasExport at line 34
HasExport disableExporter(bool $disable = true)

Disable export.

Parameters

bool $disable

Return Value

HasExport

in HasExport at line 44
string renderExportButton()

Render export button.

Return Value

string

in HasExport at line 57
HasExport exporter($exporter)

Set exporter driver for Grid to export.

Parameters

$exporter

Return Value

HasExport

in HasExport at line 72
string getExportUrl(int $scope = 1, null $args = null)

Get the export url.

Parameters

int $scope
null $args

Return Value

string

in HasExport at line 88
protected handleExportRequest(bool $forceExport = false)

Handle export request.

Parameters

bool $forceExport

in HasExport at line 111
protected AbstractExporter getExporter(string $scope)

No description

Parameters

string $scope

Return Value

AbstractExporter

in HasFilter at line 27
Filter getFilter()

获取筛选

Return Value

Filter

in HasFilter at line 37
array|Collection|mixed applyFilter(bool $toArray = true)

执行查询器

Parameters

bool $toArray

Return Value

array|Collection|mixed

in HasFilter at line 46
filter(Closure $callback)

Set the grid filter.

Parameters

Closure $callback

in HasFilter at line 57
Factory|View|string renderFilter()

Render the grid filter.

Return Value

Factory|View|string

Exceptions

Throwable

in HasFilter at line 67
protected $this initFilter()

初始化筛选

Return Value

$this

in HasQuickSearch at line 35
QuickSearch quickSearch($search = null)

No description

Parameters

$search

Return Value

QuickSearch

in HasQuickSearch at line 54
protected mixed|void applyQuickSearch()

Apply the search query to the query.

Return Value

mixed|void

in HasQuickSearch at line 83
protected addWhereBindings(string $query)

Add where bindings.

Parameters

string $query

in HasQuickSearch at line 127
protected array parseQueryBindings(array $queries)

Parse quick query bindings.

Parameters

array $queries

Return Value

array

in HasQuickSearch at line 165
protected addWhereLikeBinding(string $column, bool $or, string $pattern)

Add where like binding to model query.

Parameters

string $column
bool $or
string $pattern

in HasQuickSearch at line 183
protected addWhereDatetimeBinding(string $column, bool $or, string $function, string $value)

Add where date time function binding to model query.

Parameters

string $column
bool $or
string $function
string $value

in HasQuickSearch at line 198
protected addWhereInBinding(string $column, bool $or, bool $not, string $values)

Add where in binding to the model query.

Parameters

string $column
bool $or
bool $not
string $values

in HasQuickSearch at line 223
protected addWhereBetweenBinding(string $column, bool $or, string $start, string $end)

Add where between binding to the model query.

Parameters

string $column
bool $or
string $start
string $end

in HasQuickSearch at line 238
protected addWhereBasicBinding(string $column, bool $or, string $operator, string $value)

Add where basic binding to the model query.

Parameters

string $column
bool $or
string $operator
string $value

in HasTools at line 27
void tools(Closure $callback)

Setup grid tools.

Parameters

Closure $callback

Return Value

void

in HasTools at line 37
string renderHeaderTools()

Render custom tools.

Return Value

string

in HasTools at line 48
protected HasTools initTools(Grid $grid)

Setup grid tools.

Parameters

Grid $grid

Return Value

HasTools

in HasTotalRow at line 23
$this addTotalRow(string $column, Closure $callback)

No description

Parameters

string $column
Closure $callback

Return Value

$this

in HasTotalRow at line 33
Factory|View|string renderTotalRow($columns = null)

No description

Parameters

$columns

Return Value

Factory|View|string

in HasActions at line 37
$this actions(Closure|string $actions)

Set grid action callback.

Parameters

Closure|string $actions

Return Value

$this

in HasActions at line 51
string getActionClass()

Get action display class.

Return Value

string

in HasActions at line 65
$this setActionClass(string $actionClass)

No description

Parameters

string $actionClass

Return Value

$this

in HasActions at line 80
HasActions batchActions(array $array)

Set grid batch-action callback.

Parameters

array $array

Return Value

HasActions

in HasActions at line 91
Grid|mixed disableBatchActions(bool $disable = true)

No description

Parameters

bool $disable

Return Value

Grid|mixed

in HasActions at line 104
string renderBatchActions()

Render create button for grid.

Return Value

string

in HasActions at line 118
string skeletonBatchActions()

Render create button for grid.

Return Value

string

in HasSelector at line 22
$this selector(Closure $closure)

No description

Parameters

Closure $closure

Return Value

$this

in HasSelector at line 40
Factory|View|string renderSelector()

Render grid selector.

Return Value

Factory|View|string

in HasSelector at line 50
protected $this applySelectorQuery()

Apply selector query to grid model query.

Return Value

$this

in CanHidesColumns at line 26
bool disableColumnSelector(bool $disable = true)

Remove column selector on grid.

Parameters

bool $disable

Return Value

bool

in CanHidesColumns at line 34
bool showColumnSelector()

No description

Return Value

bool

in CanHidesColumns at line 46
CanHidesColumns hideColumns(array|string $columns)

Setting default shown columns on grid.

Parameters

array|string $columns

Return Value

CanHidesColumns

in CanHidesColumns at line 65
Collection visibleColumns()

Get all visible column instances.

Return Value

Collection

in CanHidesColumns at line 85
array visibleColumnNames()

Get all visible column names.

Return Value

array

in CanHidesColumns at line 105
array getDefaultVisibleColumnNames()

Get default visible column names.

Return Value

array

in CanHidesColumns at line 121
protected array getVisibleColumnsFromQuery()

Get visible columns from request query.

Return Value

array

in PoppyTrait at line 41
protected AuthManager pyAuth()

get auth

Return Value

AuthManager

in PoppyTrait at line 50
protected Translator pyTranslator()

get translator

Return Value

Translator

in PoppyTrait at line 60
protected Repository pyConfig()

Get configuration instance.

Return Value

Repository

in PoppyTrait at line 70
protected DatabaseManager pyDb()

get db

Return Value

DatabaseManager

in PoppyTrait at line 79
protected Kernel pyConsole()

Get console instance.

Return Value

Kernel

in PoppyTrait at line 88
protected Container pyContainer()

Get IoC Container.

Return Value

Container

| Application

in PoppyTrait at line 97
protected Mailer pyMailer()

Get mailer instance.

Return Value

Mailer

in PoppyTrait at line 106
protected SessionManager|Store pySession()

Get session instance.

Return Value

SessionManager|Store

in PoppyTrait at line 115
protected Request pyRequest()

get request

Return Value

Request

in PoppyTrait at line 125
protected Redirector pyRedirector()

get redirector

Return Value

Redirector

in PoppyTrait at line 134
protected Factory pyValidation()

get validation

Return Value

Factory

in PoppyTrait at line 144
protected Dispatcher pyEvent()

get event

Return Value

Dispatcher

in PoppyTrait at line 154
protected LoggerInterface pyLogger()

get logger

Return Value

LoggerInterface

in PoppyTrait at line 164
protected ResponseFactory pyResponse()

get response

Return Value

ResponseFactory

in PoppyTrait at line 174
protected Filesystem pyFile()

get file

Return Value

Filesystem

in PoppyTrait at line 184
protected UrlGenerator pyUrl()

get url

Return Value

UrlGenerator

in PoppyTrait at line 195
protected mixed pyCache(string $tag = '')

get cache

Parameters

string $tag tag

Return Value

mixed

in PoppyTrait at line 209
protected RedisManager pyRedis()

get redis

Return Value

RedisManager

in PoppyTrait at line 218
protected Factory pyView()

get view

Return Value

Factory

in PoppyTrait at line 227
protected Poppy pyPoppy()

get poppy

Return Value

Poppy

in PoppyTrait at line 236
protected Ini pyIni()

Ini Parser

Return Value

Ini

in PoppyTrait at line 245
protected Xml pyXml()

Ini Parser

Return Value

Xml

in PoppyTrait at line 254
protected Yaml pyYaml()

Yaml Parser

Return Value

Yaml

in LayDefines at line 33
protected layPrependRowSelectorColumn()

增加行选择器

in LayDefines at line 42
protected layFormat()

Layui 格式化

in LayDefines at line 52
protected layColumns()

列样式

in LayDefines at line 84
protected false|string layDefine()

定义 Layui 的数据定义

Return Value

false|string

in HasQuickButton at line 17
array appendQuickButton(array $buttons)

Get create url.

Parameters

array $buttons

Return Value

array

in HasQuickButton at line 33
string renderQuickButton()

Render create button for grid.

Return Value

string

in HasQuickButton at line 42
array skeletonQuickButton()

No description

Return Value

array

at line 158
__construct(Model $model, Closure $builder = null)

Create a new grid instance.

Parameters

Model $model
Closure $builder

at line 176
Model model()

Get Grid model.

Return Value

Model

at line 187
setLists(string $grid_class, string $field = '', string $order = 'desc')

No description

Parameters

string $grid_class
string $field
string $order

Exceptions

ApplicationException

at line 227
$this|mixed option(string $key, mixed $value = null)

Get or set option for grid.

Parameters

string $key
mixed $value

Return Value

$this|mixed

at line 243
string getKeyName()

Get primary key name of model.

Return Value

string

at line 255
void paginate(int $perPage = 15)

Paginate the grid.

Parameters

int $perPage

Return Value

void

at line 267
mixed paginator()

Get the grid paginator.

Return Value

mixed

at line 282
perPages(array $perPages)

设置分页的可选条目数

Parameters

array $perPages

at line 293
Grid disableRowSelector(bool $disable = true)

Disable row selector.

Parameters

bool $disable

Return Value

Grid

at line 303
void build()

Build the grid.

Return Value

void

at line 319
rows(Closure $callable = null)

Set grid row callback function.

Parameters

Closure $callable

at line 328
string resource()

Get current resource url.

Return Value

string

at line 340
Grid with(array $variables = [])

Add variables to grid view.

Parameters

array $variables

Return Value

Grid

at line 353
setView(string $view, array $variables = [])

Set a view to render.

Parameters

string $view
array $variables

at line 369
Grid setTitle(string $title)

Set grid title.

Parameters

string $title

Return Value

Grid

at line 383
Grid rendering(callable $callback)

Set rendering callback.

Parameters

callable $callback

Return Value

Grid

at line 396
string render()

Get the string contents of the grid view.

Return Value

string

Exceptions

Throwable

at line 423
int getPerPage()

No description

Return Value

int

at line 428
skeleton()

No description

at line 473
static init(Closure $callback = null)

Initialize with user pre-defined default disables and exporter, etc.

Parameters

Closure $callback

at line 481
protected initialize()

Initialize.

at line 495
protected callInitCallbacks()

Call the initialization closure array in sequence.

at line 511
protected void prependRowSelectorColumn()

添加多选框列

Return Value

void

at line 525
protected void applyColumnFilter()

Apply column filter to grid query.

Return Value

void

at line 537
protected void applyColumnSearch()

Apply column search to grid query.

Return Value

void

at line 547
protected array|Collection|mixed applyQuery()

No description

Return Value

array|Collection|mixed

at line 564
protected void addDefaultColumns()

添加多选 / 操作项目

Return Value

void

at line 576
protected void buildRows(array $data)

Build the grid rows.

Parameters

array $data

Return Value

void

at line 592
protected array variables()

Get all variables will used in grid view.

Return Value

array

at line 610
protected void callRenderingCallback()

Call callbacks before render.

Return Value

void