Back to [[:start|Start Page]]\\
====== List Switch: How to manage Backend Lists a little more convenient =======
=== What it will look like: ===
{{:developers:listswitchbyinetis_prev.jpg?direct&600|}}
(screenshot from plugin page [[https://octobercms.com/plugin/inetis-listswitch]])
When working with datatables one may come across fields containing simple on/off or cheched/unchecked functionality. Although OrctoberCms backend list already contains a column type named switch, this one is display only without any functionality. This means whenever a status like on/off has to be changed for more than one record, it is necessary to open the records form, update and save, open the next record and so on.
Often a more convenient way to manage data - for example to switch visibility of many items like pictures or products on and off is to do this via a list view. That is exactly what the List Switch plugin provides thankfully.
The plugin can be found on the OC homepage > plugins, search for 'Inetis' and/or 'list switch'.\\
{{:developers:listswitchbyinetis.jpg?direct&800|}}
\\
Anyhow there is a downside for this plugin, because the Builder Plugin does not allow custom defined column types (unlike form field types). So it is necessary to use an editor e.g. like the one from the [[:developers:plugin_developertools |Developer Tools Plugin]] to edit the models *columns.yaml* file.\\
Here is an example with the built in switch and the inetis-list-switch.\\
**Standard switch (before)**
columns:
id:
label: ID
type: number
sortable: true
title:
label: Title
type: text
searchable: true
sortable: true
visible:
label: Visible
type: switch
**List Switch Plugin (after)**
columns:
id:
label: ID
type: number
sortable: true
title:
label: Title
type: text
searchable: true
sortable: true
visible:
label: Visible
type: inetis-list-switch
icon: true
The //icon: true// setting shows a hooklet for //on// and a 'x' for //off//. With //icon: false// the text //yes// or //no// is displayed by default.\\
If neither a hooklet/x or yes/no fits the requirements, an alternative text can be displayed using:\\
columns:
id:
label: ID
type: number
sortable: true
title:
label: Title
type: text
searchable: true
sortable: true
visible:
label: Visible
type: inetis-list-switch
icon: false
textTrue: 'visible' # instead of 'yes'
textFalse: 'invisible' # instead of 'no'