I have added a button in pimcore panel in object editor. On button click how can I fetch selected records from the table?
Table:
So far I have tried this:
postOpenObject: function (object, type) {
object.toolbar.add({
iconCls: 'pimcore_icon_export',
scale: 'small',
handler: function () {
const req = new XMLHttpRequest();
// I need to pass selected items in a function
req.open("GET", '/admin/export-xyz/', true);
}.bind(this, object)
});
pimcore.layout.refresh();
},
As you are passing object
in bind, you can object.search.grid.getSelectionModel().getSelection();
Then make a loop to find the selected row.
handler: function () {
const req = new XMLHttpRequest();
// I need to pass selected items in a function
let selections = object.search.grid.getSelectionModel().getSelection();
for (let i= 0; i < selections.length; i++) {
console.log(selections[i].id);
}
req.open("GET", '/admin/export-xyz/', true);
}.bind(this, object)