Zum Hauptinhalt springen

Schaltflächen

Im folgenden Beispiel werden Schaltflächen oberhalb der Tabelle hinzugefügt.

context.enableModules();
const { TableMonitor } = require("ou.sp.gadget.TableMonitor");

context.returnValue = TableMonitor.show({
...
buttons: {
add: {
label: "Hinzufügen",
click: function (button, options) {
options.rows.push({
icon: "entypo:check",
id: "4321"
})
}
},
copy: {
label: "Kopieren",
tooltip: "Zeile kopieren",
click: function (button, options) {
options.rows.push.apply(options.rows, options.selectedRows.slice())
},
enabled: function (selectedRows, options) {
return selectedRows.length > 0
}
},
remove: {
label: "Löschen",
tooltip: "Zeile löschen",
click: function (button, options) {
options.removeSelectedRows()
},
enabled: function (selectedRows, options) {
return selectedRows.length > 0
}
},
moveUp: {
label: '<span class="ionicon ion-ios-arrow-round-up"></span>',
tooltip: "Zeile nach oben",
click: function (button, options) {
var currentIndex = options.rows.indexOf(options.selectedRows[0])
options.moveSelectedRow(currentIndex - 1)
},
enabled: function (selectedRows, options) {
return selectedRows.length == 1 && options.rows.indexOf(selectedRows[0]) > 0
}
},
moveDown: {
label: '<span class="ionicon ion-ios-arrow-round-down"></span>',
tooltip: "Zeile nach unten",
click: function (button, options) {
var currentIndex = options.rows.indexOf(options.selectedRows[0])
options.moveSelectedRow(currentIndex + 1)
},
enabled: function (selectedRows, options) {
return selectedRows.length == 1 && options.rows.indexOf(selectedRows[0]) <= selectedRows.length
}
}
}
})