Ext this.getView(...).saveDocumentAs is not a function

1、前言

  Ext 導出數據,根據官網的代碼,報:this.getView(...).saveDocumentAs is not a function 的問題。php

  參考:Ext Export not workingthis

  官網代碼:spa

  

2、解決方案

  主要的緣由仍是覺得找不到 Grid 的問題。我參考中使用的是 Ext.ComponentQuery.query('grid')[0]; 來尋找 Grid ,若是 一個 view 中有兩個 grid 咱們須要找,看看是那個 grid,不一樣通用。因此我使用的方式是經過傳入的 btn 來找最近的 grid。完美解決還通用3d

    exportTo: function (btn) {

        var cfg = Ext.merge({
            title: 'Grid export demo',
            fileName: 'GridExport' + '.' + (btn.cfg.ext || btn.cfg.type)
        }, btn.cfg);

        //參考的
        var p = Ext.ComponentQuery.query('grid')[0];
        p.saveDocumentAs(cfg)//若是一個view中有兩個 grid 不適用

        //本身推到的
        this.getView().query('grid')[0].saveDocumentAs(cfg);//若是一個view中有兩個 grid 不適用

        //最後使用
        btn.up('grid').saveDocumentAs(cfg);//通用
    },
相關文章
相關標籤/搜索