-
Notifications
You must be signed in to change notification settings - Fork 145
Grid view #5990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dtdesign
reviewed
Sep 19, 2024
47ab3ce to
0b75b22
Compare
Hanashi
reviewed
Nov 18, 2024
wcfsetup/install/files/lib/system/gridView/filter/TextFilter.class.php
Outdated
Show resolved
Hide resolved
Hanashi
reviewed
Nov 18, 2024
wcfsetup/install/files/lib/system/gridView/filter/I18nTextFilter.class.php
Outdated
Show resolved
Hide resolved
This was referenced Nov 24, 2024
Grid views are now always based on `DatabaseObjectList`
This was referenced Jan 27, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Grid view is a generic solution for the creation of listings, as they occur again and again in the software. In addition to rendering, the grid view also take care of sorting, filtering and pagination and ensure that a lot of boilerplating becomes obsolete.
The implementation essentially offers the following advantages:
See #5967
Usage
CronjobLogGridView is available as a reference implementation.
DatabaseObjectListGridView
DatabaseObjectListGridViewallows to use aDatabaseObjectListas the data source for the grid view.Example:
DataSourceGridView
DataSourceGridViewuse an array as the data source for the grid view.Example:
AbstractGridViewPage
With the help of
AbstractGridViewPage, grid views can be easily integrated into pages.Example:
Template:
Columns
Columns can be created using the
GridViewColumn::formethod. This expects a unique string as a parameter, which is equivalent to the corresponding key in the data source.The
labelmethod can be used to give the column a human readable label.Example:
Renderer
Renderers can be applied to columns to format the output. A column can have multiple renderers. The renderers are applied in the order in which they were set.
CurrencyColumnRenderer
CurrencyColumnRendererformats the content of a column as a currency. Expects the content of the column to be a decimal.Example:
DefaultColumnRenderer
The
DefaultColumnRendereris automatically applied to all columns if no other renderers have been set. It converts special characters to HTML entities.IpAddressColumnRenderer
IpAddressColumnRendererrenders ipv6 embedded ipv4 address into ipv4 or returns input if true ipv6.Example:
LinkColumnRenderer
LinkColumnRendererallows the setting of a link to a column.Example:
NumberColumnRenderer
NumberColumnRendererformats the content of a column as a number usingStringUtil::formatNumeric().Example:
PhraseColumnRenderer
PhraseColumnRendererformats the content of a column as a phrase.Example:
TimeColumnRenderer
TimeColumnRendererrenders a unix timestamp into a human readable format.Example:
TitleColumnRenderer
TitleColumnRendererformats the content of a column as a title.Example:
TruncatedTextColumnRenderer
TruncatedTextColumnRenderertruncates the content of a column to a length of 80 characters (default value).Example:
UserColumnRenderer
UserColumnRendererformats the content of a column as a user.Example:
Row Link
A row link applies a link to every column in the grid.
The constructor supports 3 optional parameters:
string $controllerClass: The controller to which the link should refer.array $parameters: Additional parameters for the controller.string $cssClass: CSS class for the link.Sorting
Columns can be marked as sortable so that the user has the option of sorting according to the content of the column.
Default Sort Field
The default sort field and sort order can be set when building the grid view:
Filtering
Filters can be defined for columns so that the user has the option of filtering according to the content of the column.
I18nTextFilter
I18nTextFilteris a filter for text columns that are using i18n phrases.Example:
IpAddressFilter
IpAddressFilteris a filter for columns that contain ipv6 addresses, allowing the user to enter addresses in the ipv4 format.Example:
SelectFilter
SelectFilterallows a column to be filtered on the basis of a select dropdown.Example:
TextFilter
TextFilteris a filter for text columns.Example:
TimeFilter
TimeFilteris a filter for columns that contain unix timestamps.Example:
UserFilter
UserFilteris a filter for columns that contain user ids.Example:
Actions
Actionsare actions that the user can apply to a row in the grid view. Typical use cases are deleting and editing.By default, actions are made accessible via a dropdown. Special actions are so-called “quick actions”, which can be controlled directly via their own icons.
DeleteAction
DeleteActionallows the user to delete a row of the grid view. The constructor expects the RPC API endpoint for deletion as a parameter.Example:
EditAction
EditActionadds a link to the corresponding edit form. The constructor expects the name of the controller as a parameter.Example:
ToggleAction
ToggleActionallows the user to enable/disable a row of the grid view. The constructor expects the RPC API endpoints for enabling and disabling as parameters.Example:
Events
Existing grid views can be modified using events. Example of adding an additional column:
Planned Functions