ilhan
ilhan

Reputation: 8935

Downloading a file (Excel file) with store.load? (ExtJS 4.1)

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.

Upvotes: 0

Views: 2359

Answers (2)

jorel
jorel

Reputation: 808

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.

Upvotes: 1

sha
sha

Reputation: 17860

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

Content-disposition: attachment

Upvotes: 0

Related Questions