class Grid

Traits

是否开启筛选

Layui 的参数定义

Trait HasQuickSearch.

Macroable
PoppyTrait

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 $batchOperations 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 array $quickButtons 快捷操作 from  HasQuickButton
protected $operations from  HasQuickButton
static protected $initCallbacks

Initialization closure array.

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 built.

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.

Methods

string
getName()

Get name of grid.

$this
setName(string $name)

Set name to 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.

bool
isShowTools()

是否显示导出按钮

from  HasTools
disableTools(bool $disable = true)

Disable export.

from  HasTools
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($buttons)

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
renderSelector()

Render grid selector.

$this
applySelectorQuery()

Apply selector query to grid model query.

column(string $name, string $label = '')

Add a column to Grid.

__call(string $method, array $parameters)

Dynamically add columns to the grid view.

Collection
getColumns()

No description

applyColumnOrderBy()

No description

addRelationColumn(string $name, string $label = '')

Add a relation column to grid.

addJsonColumn(string $name, string $label = '')

Add a json type column to grid.

prependColumn(string $name = '', string $label = '')

Prepend column to grid.

addColumn(string $name = '', string $label = '')

Add column to grid.

bool|Column
handleGetMutatorColumn(string $method, string $label)

Handle get mutator column for grid.

bool|Column
handleRelationColumn(string $method, string $label)

Handle relation column for grid.

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()

列样式

string
layDefine()

定义 Layui 的数据定义

bool
isShowQuickButton()

是否显示导出按钮

disableQuickButton(bool $disable = true)

Disable export.

array
appendQuickButton(array|Closure $buttons)

Get create url.

string
renderQuickButton()

Render create button for grid.

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

Create a new grid instance.

static 
init(Closure $callback = null)

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

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

void
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 be used in grid view.

void
callRenderingCallback()

Call callbacks before render.

Details

in HasElementNames at line 33
string getName()

Get name of grid.

Return Value

string

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

Set name to grid.

Parameters

string $name

Return Value

$this

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 25
bool isShowExporter()

是否显示导出按钮

Return Value

bool

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

Disable export.

Parameters

bool $disable

Return Value

HasExport

in HasExport at line 46
string renderExportButton()

Render export button.

Return Value

string

in HasExport at line 59
HasExport exporter($exporter)

Set exporter driver for Grid to export.

Parameters

$exporter

Return Value

HasExport

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

Get the export url.

Parameters

int $scope
null $args

Return Value

string

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

Handle export request.

Parameters

bool $forceExport

in HasExport at line 113
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 37
QuickSearch quickSearch($search = null)

No description

Parameters

$search

Return Value

QuickSearch

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

Apply the search query to the query.

Return Value

mixed|void

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

Add where bindings.

Parameters

string $query

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

Parse quick query bindings.

Parameters

array $queries

Return Value

array

in HasQuickSearch at line 167
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 185
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 200
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 225
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 240
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 23
bool isShowTools()

是否显示导出按钮

Return Value

bool

in HasTools at line 34
HasTools disableTools(bool $disable = true)

Disable export.

Parameters

bool $disable

Return Value

HasTools

in HasTools at line 46
HasTools tools(Closure $callback)

Setup grid tools.

Parameters

Closure $callback

Return Value

HasTools

in HasTools at line 57
string renderHeaderTools()

Render custom tools.

Return Value

string

in HasTools at line 68
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 43
$this actions(Closure|string $actions)

Set grid action callback.

Parameters

Closure|string $actions

Return Value

$this

in HasActions at line 57
string getActionClass()

Get action display class.

Return Value

string

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

No description

Parameters

string $actionClass

Return Value

$this

in HasActions at line 86
HasActions batchActions($buttons)

Set grid batch-action callback.

Parameters

$buttons

Return Value

HasActions

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

No description

Parameters

bool $disable

Return Value

Grid|mixed

in HasActions at line 123
string renderBatchActions()

Render create button for grid.

Return Value

string

in HasActions at line 142
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 37
Factory|View renderSelector()

Render grid selector.

Return Value

Factory|View

in HasSelector at line 47
protected $this applySelectorQuery()

Apply selector query to grid model query.

Return Value

$this

in HasColumns at line 36
Column column(string $name, string $label = '')

Add a column to Grid.

Parameters

string $name
string $label

Return Value

Column

Exceptions

ApplicationException

in HasColumns at line 57
Column __call(string $method, array $parameters)

Dynamically add columns to the grid view.

Parameters

string $method
array $parameters

Return Value

Column

in HasColumns at line 83
Collection getColumns()

No description

Return Value

Collection

in HasColumns at line 90
protected applyColumnOrderBy()

No description

in HasColumns at line 108
protected Column addRelationColumn(string $name, string $label = '')

Add a relation column to grid.

Parameters

string $name
string $label

Return Value

Column

Exceptions

ApplicationException

in HasColumns at line 134
protected Column addJsonColumn(string $name, string $label = '')

Add a json type column to grid.

Parameters

string $name
string $label

Return Value

Column

in HasColumns at line 151
protected Column prependColumn(string $name = '', string $label = '')

Prepend column to grid.

Parameters

string $name
string $label

Return Value

Column

in HasColumns at line 169
protected Column addColumn(string $name = '', string $label = '')

Add column to grid.

Parameters

string $name
string $label

Return Value

Column

in HasColumns at line 187
protected bool|Column handleGetMutatorColumn(string $method, string $label)

Handle get mutator column for grid.

Parameters

string $method
string $label

Return Value

bool|Column

in HasColumns at line 204
protected bool|Column handleRelationColumn(string $method, string $label)

Handle relation column for grid.

Parameters

string $method
string $label

Return Value

bool|Column

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

Remove column selector on grid.

Parameters

bool $disable

Return Value

bool

in CanHidesColumns at line 33
bool showColumnSelector()

No description

Return Value

bool

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

Setting default shown columns on grid.

Parameters

array|string $columns

Return Value

CanHidesColumns

in CanHidesColumns at line 64
Collection visibleColumns()

Get all visible column instances.

Return Value

Collection

in CanHidesColumns at line 84
array visibleColumnNames()

Get all visible column names.

Return Value

array

in CanHidesColumns at line 104
array getDefaultVisibleColumnNames()

Get default visible column names.

Return Value

array

in CanHidesColumns at line 120
protected array getVisibleColumnsFromQuery()

Get visible columns from request query.

Return Value

array

in PoppyTrait at line 43
protected AuthManager pyAuth()

get auth

Return Value

AuthManager

in PoppyTrait at line 52
protected Translator pyTranslator()

get translator

Return Value

Translator

in PoppyTrait at line 62
protected Repository pyConfig()

Get configuration instance.

Return Value

Repository

in PoppyTrait at line 72
protected DatabaseManager pyDb()

get db

Return Value

DatabaseManager

in PoppyTrait at line 81
protected Kernel pyConsole()

Get console instance.

Return Value

Kernel

in PoppyTrait at line 90
protected Container pyContainer()

Get IoC Container.

Return Value

Container

| Application

in PoppyTrait at line 99
protected Mailer pyMailer()

Get mailer instance.

Return Value

Mailer

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

Get session instance.

Return Value

SessionManager|Store

in PoppyTrait at line 117
protected Request pyRequest()

get request

Return Value

Request

in PoppyTrait at line 127
protected Redirector pyRedirector()

get redirector

Return Value

Redirector

in PoppyTrait at line 136
protected Factory pyValidation()

get validation

Return Value

Factory

in PoppyTrait at line 146
protected Dispatcher pyEvent()

get event

Return Value

Dispatcher

in PoppyTrait at line 156
protected LoggerInterface pyLogger()

get logger

Return Value

LoggerInterface

in PoppyTrait at line 166
protected ResponseFactory pyResponse()

get response

Return Value

ResponseFactory

in PoppyTrait at line 176
protected Filesystem pyFile()

get file

Return Value

Filesystem

in PoppyTrait at line 186
protected UrlGenerator pyUrl()

get url

Return Value

UrlGenerator

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

get cache

Parameters

string $tag tag

Return Value

mixed

in PoppyTrait at line 211
protected RedisManager pyRedis()

get redis

Return Value

RedisManager

in PoppyTrait at line 220
protected Factory pyView()

get view

Return Value

Factory

in PoppyTrait at line 229
protected Poppy pyPoppy()

get poppy

Return Value

Poppy

in PoppyTrait at line 238
protected Ini pyIni()

Ini Parser

Return Value

Ini

in PoppyTrait at line 247
protected Xml pyXml()

Ini Parser

Return Value

Xml

in PoppyTrait at line 256
protected Yaml pyYaml()

Yaml Parser

Return Value

Yaml

in LayDefines at line 35
protected layPrependRowSelectorColumn()

增加行选择器

in LayDefines at line 44
protected layFormat()

Layui 格式化

in LayDefines at line 54
protected layColumns()

列样式

in LayDefines at line 67
protected string layDefine()

定义 Layui 的数据定义

Return Value

string

in HasQuickButton at line 22
bool isShowQuickButton()

是否显示导出按钮

Return Value

bool

in HasQuickButton at line 33
HasQuickButton disableQuickButton(bool $disable = true)

Disable export.

Parameters

bool $disable

Return Value

HasQuickButton

in HasQuickButton at line 44
array appendQuickButton(array|Closure $buttons)

Get create url.

Parameters

array|Closure $buttons

Return Value

array

in HasQuickButton at line 68
string renderQuickButton()

Render create button for grid.

Return Value

string

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

Create a new grid instance.

Parameters

Model $model
Closure $builder

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

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

Parameters

Closure $callback

at line 199
Model model()

Get Grid model.

Return Value

Model

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

No description

Parameters

string $grid_class
string $field
string $order

Return Value

Grid

Exceptions

ApplicationException

at line 262
$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 278
string getKeyName()

Get primary key name of model.

Return Value

string

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

Paginate the grid.

Parameters

int $perPage

Return Value

void

at line 302
mixed paginator()

Get the grid paginator.

Return Value

mixed

at line 317
perPages(array $perPages)

设置分页的可选条目数

Parameters

array $perPages

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

Disable row selector.

Parameters

bool $disable

Return Value

Grid

at line 338
void build()

Build the grid.

Return Value

void

at line 354
rows(Closure $callable = null)

Set grid row callback function.

Parameters

Closure $callable

at line 363
string resource()

Get current resource url.

Return Value

string

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

Add variables to grid view.

Parameters

array $variables

Return Value

Grid

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

Set a view to render.

Parameters

string $view
array $variables

at line 402
Grid setTitle(string $title)

Set grid title.

Parameters

string $title

Return Value

Grid

at line 415
Grid rendering(callable $callback)

Set rendering callback.

Parameters

callable $callback

Return Value

Grid

at line 428
string render()

Get the string contents of the grid view.

Return Value

string

Exceptions

Throwable

at line 451
int getPerPage()

No description

Return Value

int

at line 459
protected void initialize()

Initialize.

Return Value

void

at line 473
protected callInitCallbacks()

Call the initialization closure array in sequence.

at line 489
protected void prependRowSelectorColumn()

添加多选框列

Return Value

void

at line 503
protected void applyColumnFilter()

Apply column filter to grid query.

Return Value

void

at line 515
protected void applyColumnSearch()

Apply column search to grid query.

Return Value

void

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

No description

Return Value

array|Collection|mixed

at line 544
protected void addDefaultColumns()

添加多选 / 操作项目

Return Value

void

at line 556
protected void buildRows(array $data)

Build the grid rows.

Parameters

array $data

Return Value

void

at line 572
protected array variables()

Get all variables will be used in grid view.

Return Value

array

at line 590
protected void callRenderingCallback()

Call callbacks before render.

Return Value

void