如何在对象编辑器 pimcore 中单击按钮时从 table 中获取选定的项目?
How to get selected item from table on button click in object editor pimcore?
我在对象编辑器的 pimcore 面板中添加了一个按钮。在按钮上单击如何从 table?
中获取选定的记录
Table:
到目前为止我试过这个:
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();
},
当您在绑定中传递 object
时,您可以 object.search.grid.getSelectionModel().getSelection();
然后循环查找所选行。
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)
我在对象编辑器的 pimcore 面板中添加了一个按钮。在按钮上单击如何从 table?
中获取选定的记录Table:
到目前为止我试过这个:
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();
},
当您在绑定中传递 object
时,您可以 object.search.grid.getSelectionModel().getSelection();
然后循环查找所选行。
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)