Page 30 of 30 FirstFirst ... 20282930
Results 291 to 296 of 296

Thread: GridPanel directly to Excel.

  1. #291
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    54
    Vote Rating
    1
      0  

    Default

    I was not able to test it so far, but I think this code will work:
    Code:
    //      Generate the data rows from the data in the Store
            var treeAsArray = new Array();
            this.store.getRootNode().cascadeBy(
                function(node){
                    if (node.get('id') !== 'root') treeAsArray.push(node);
                },
                this
            );        
            
            for (var i = 0, it = treeAsArray, l = it.length; i < l; i++) {
    ...

  2. #292
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    54
    Vote Rating
    1
      0  

    Default

    But perhaps someone can help me with the LinkButton. It doesn't work for me:
    Code:
    Ext.define('IGP_Office.view.LinkCSVButton', {
        extend: 'Ext.button.Button',
        alias: 'widget.linkCSVButton',
    
    
        icon: 'resources/icons/csv.png',
        text: 'CSV export',
    
    
        initComponent: function() {
            var me = this;
    
    
            Ext.applyIf(me, {
                listeners: {
                    click: {
                        fn: me.onButtonClick,
                        scope: me
                    },
                    render: {
                        fn: me.onButtonRender,
                        scope: me
                    }
                }
            });
    
    
            me.processLinkCSVButton(me);
            me.callParent(arguments);
        },
    
    
        processLinkCSVButton: function(config) {
            config.template = new Ext.Template(
                    '<table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>',
                    '<td class="x-btn-left"><i> </i></td><td class="x-btn-center"><a class="x-btn-text" href="{1}" target="{2}">{0}</a></td><td class="x-btn-right"><i> </i></td>',
                    '</tr></tbody></table>');
            return config;
        },
    
    
        onButtonClick: function(button, e, eOpts) {
            if (e.button != 0) {
                return;
            }
            if (!this.disabled) {
                this.fireEvent("click", this, e);
                if (this.handler) {
                    this.handler.call(this.scope || this, this, e);
                }
            }
        },
    
    
        onButtonRender: function(component, eOpts) {
            var btn, targs = [this.text || ' ', this.href, this.target || "_self"];
            if (eOpts) {
                btn = this.template.insertBefore(eOpts, targs, true);
            } else {
                btn = this.template.append(component, targs, true);
            }
            var btnEl = btn.child("a:first");
            btnEl.on('focus', this.onFocus, this);
            btnEl.on('blur', this.onBlur, this);
    
    
    
    
            this.initButtonEl(btn, btnEl);
            Ext.ButtonToggleMgr.register(this);
        }
    
    
    });
    The line
    Code:
    btn = this.template.insertBefore(...
    throws an error, because this.template is undefined.

    Thanks a lot.

    Tobias

  3. #293
    Sencha Premium Member
    Join Date
    Nov 2013
    Posts
    54
    Vote Rating
    1
      0  

    Default

    You can add this part of code to the override. Then you can simply call downloadExcelXml() in a button-handler to name the file and get a link - button:
    Code:
    downloadExcelXml: function(includeHidden, title) {
    
    
            var vExportContent = this.getExcelXml(includeHidden, title);
    
    
            var location = 'data:application/vnd.msexcel;base64,' + Base64.encode(vExportContent);
    
    
            if (!title) title = this.title;
    
    
            /* 
              dynamically create and anchor tag to force download with suggested filename 
              note: download attribute is Google Chrome specific
            */
            var gridEl = this.getEl();
    
    
            var el = Ext.DomHelper.append(gridEl, {
                tag: "a",
                download: title + "-" + Ext.Date.format(new Date(), 'Y-m-d H i') + '.xls',
                href: location
            });
    
    
            el.click();
    
    
            Ext.fly(el).destroy();
        },

  4. #294
    Sencha User
    Join Date
    Sep 2013
    Posts
    3
    Vote Rating
    0
      0  

    Default

    Good work!

  5. #295
    Sencha User
    Join Date
    Oct 2014
    Posts
    1
    Vote Rating
    0
      0  

    Default

    I was wondering where do you create the file name for the export and is it possible to change it?

  6. #296
    Sencha Premium Member
    Join Date
    Apr 2015
    Posts
    14
    Vote Rating
    0
      0  

    Default

    Has anyone had issues opening the excel file with IE11? Chrome works fine, but in IE the URL opens in a new tab but I am not given an option to download. I do not have access to "My Computer" to change the "Browse in same window" options. Any other options?

Page 30 of 30 FirstFirst ... 20282930

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •