ExtJS仅导出选定的行

时间:2018-11-27 16:05:13

标签: extjs

如何仅导出选定的行?

下面的代码导出页面中的所有行,如何在导出之前过滤掉未选中的行?

 list.saveDocumentAs({
        type: 'xlsx',
        title: 'Account',
        fileName: 'Account.xlsx'
    });

1 个答案:

答案 0 :(得分:0)

我最终创建了带有复选框项目的另一列,将每行的复选框标记同步到该列,并在导出前按该列进行过滤,然后重置过滤。

功能最终变成这样

onExportList: function () {
    this.getView().queryById('lisatradegrid').store.filterBy(function (record, id) {
        if (record.get('isSelected'))
            return true;
        else
            return false;
    });
    list.saveDocumentAs({
        type: 'xlsx',
        title: 'Account Change',
        fileName: 'Account Change Requests.xlsx'
    });
    setTimeout(function () {
        list.store.clearFilter();
    }, 1000);      
},