context.enableModules();
const { TableMonitor } = require("ou.sp.gadget.TableMonitor");
context.returnValue = TableMonitor.show({
rows: [
{
icon: "entypo:check",
id: "1234"
},
{
icon: "entypo:check",
id: "12345"
},
{
icon: "entypo:check",
id: "123456"
}
],
columns: {
icon: {
type: "icon",
label: "",
attributes: {
style: "width: 20px"
}
},
id: {
label: "Kreditorennummer",
required: true,
attributes: {
class: 'cell-id'
}
}
},
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: "multi"
},
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: "single"
},
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
}
}
}
})