Grid Column
By default, the column shows the most primitive data in the database. If you need to modify the display of the column data, refer to the following method.
Display callback
The display()
method is used to process the value of the current column via the passed callback function:
In the incoming anonymous function, the data can be processed in any way. In addition, the anonymous function binds the data of the current column as a parent object, and can call the data of the current row in the function:
Display different components according to conditions
If this column is to be displayed as a different component based on certain criteria
Content Mapping
If the value of the field gender
is f
, m
, it needs to be displayed with female
and male
respectively.
Content replacement
If you need to replace some of the values of this column with other content to display:
Column view
Use the view()
method to make the current column render a view display output, such as having a view resources/views/content.blade.php
By default, two variables of the view are passed in, $model
is the model of the current row, and $value
is the value of the current column.
Then use the following call to render this view output
This method can be used to render complex column content.
Column expansion
If there are more fields in a row, you can hide too much content by using the column expansion feature. Expand the display by clicking on the column, or click to expand other related data, such as the following example, to expand the 10 latest comments under an article:
Any content that can be rendered can be returned in the closure function.
Popup modal box
Similar to the column expansion
function, you can display more content by popping up the modal box.
Gavatar
If this column of data is a email, you want to display it as a Gavatar:
File size
If the data in this column is the number of bytes representing the file size, you can display the more readable text by calling the filezise
method.
Such a value 199812019
will be displayed as 190.56 MB
Download link
If the data in this column stores the path to the uploaded file, you can set this column as a downloadable link by calling the downloadable
method.
Copy button
With the following call, a copy icon will appear in front of each line of text in this column, click on it to copy its value
QR code
Through the following call, a QR code icon will appear in front of each line of text in this column. Click on it to expand a small bullet box, which will display the QR code of this column value.
Display image
If the picture
field holds the full address of the picture, or the path, the column can be rendered as a picture display in the following way.
Multi-graph display is supported, and field output is required as an array.
Display label
Display the field as a label
tag. If the field is output as an array, it will appear as multiple label
tags.
If you need to display the different values of the status
field as labels of different colors
Show icon
Display the field as a font-awesome
icon, more icons refer to http://fontawesome.io/icons/
link
Display the field as a link.
Table
Display the field as a table, requiring the value of the current column to be a two-dimensional array
Progress bar
Display the field as a progress bar, the value of the current column needs to be a value, the default maximum value is 100,
$style
is used to set the style, optional values danger
, warning
, info
, primary
, default
, success
$size
is used to set the size. The optional values are sm
, xs
, xxs
, $max
to set the maximum range.
Loading status
If the value of status is one of [1, 2, 3]
, it will be displayed as a loading icon.
Show other field values displayed
Image Carousel
If the field value is an image array, you can use the following call to display the image carousel component.
Date format
If the field value is a timestamp, you can format the output with the date
method.
For the format parameters, please refer to PHP's date function.
Last updated