【问题标题】:How to get selected item from table on button click in object editor pimcore?如何在对象编辑器 pimcore 中单击按钮时从表中获取选定项目?
【发布时间】:2021-12-06 05:55:30
【问题描述】:

我在对象编辑器的 pimcore 面板中添加了一个按钮。单击按钮时如何从表中获取选定的记录?

表:

到目前为止,我已经尝试过:

 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();
 },

【问题讨论】:

    标签: javascript php pimcore


    【解决方案1】:

    当你在bind中传递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)
    

    【讨论】:

      猜你喜欢
      • 2020-03-01
      • 2014-11-02
      • 1970-01-01
      • 1970-01-01
      • 2011-08-23
      • 2012-08-19
      • 2015-10-15
      • 1970-01-01
      • 2013-06-20
      相关资源
      最近更新 更多