0

I need to download a file from a grid using a button in window. In order to send the filter parameters I use store.load however it doesn't download the file but it tries to read it. Is there any solution?

store.load({
 params: {
  startExel: parseInt(Ext.getCmp('startE').getValue())
 }
});

startExel is an extra parameter in order to indicate that I want to download an Excel file.

ilhan
  • 8,700
  • 35
  • 117
  • 201

2 Answers2

1

I don't think its possible to do this by simple configuration changes. Because stores are loaded via AJAX calls.

Here is an idea for you:

  1. Return a JSON object with file download url as the response to store load request. Not the actual file contents.

    { success = false, url='...'}

  2. In client side handle the store load failure then identify and extract the returned url. You may have to tweak reader configuration a little.

  3. Call window.open(url) to initiate the file download.

See this question from SO.

Community
  • 1
  • 1
jorel
  • 808
  • 7
  • 15
0

On the server end when returning the file include the following header:

Content-disposition: attachment
sha
  • 17,824
  • 5
  • 63
  • 98