I have a page with a grid I want to export to Excel (client side) via a button.
I got it working easily on a test page.
Drop a grid, populate it with data
add a button as follows
and the javascript below
So far so good.
My "real life" page is a bit more complex...
The page is a kind of "generic report" page. I pass it a report number on the URL and it shows the various prompts and parameters related to this report.
Once the parameters entered, the user presses a button and I fire a sql server stored procedure that returns one or more "recordsets". Each recordset is shown as a grid with a couple of buttons under the grid allowing (I hope!) to export that particular grid in excel, word or CSV.
I don't do anything fancy with the grid. I had "myGrid.EnabledViewState = false" but I even removed that.
I have not setup any ExportSettings because I think this is required by the Server Side export only.
Since i can have more than one grid on the page, I pass it's clientId to the javascript call, which looks like
The alert shows me that masterTable.exportToExcel() returns False.
Any idea what I might be doing wrong?
Many Thanks
Eric
I got it working easily on a test page.
Drop a grid, populate it with data
add a button as follows
| <asp:Button ID="btnExportExcelClient" runat="server" Text="btnExportExcelClient" |
| OnClientClick="javascript:ExportToExcel();return false;" /> |
| function ExportToExcel() { |
| var masterTable = $find("<%=RadGrid1.ClientID %>").get_masterTableView(); |
| masterTable.exportToExcel(); |
| } |
So far so good.
My "real life" page is a bit more complex...
The page is a kind of "generic report" page. I pass it a report number on the URL and it shows the various prompts and parameters related to this report.
Once the parameters entered, the user presses a button and I fire a sql server stored procedure that returns one or more "recordsets". Each recordset is shown as a grid with a couple of buttons under the grid allowing (I hope!) to export that particular grid in excel, word or CSV.
I don't do anything fancy with the grid. I had "myGrid.EnabledViewState = false" but I even removed that.
I have not setup any ExportSettings because I think this is required by the Server Side export only.
Since i can have more than one grid on the page, I pass it's clientId to the javascript call, which looks like
| function ExportToExcel(radGridId) { |
| var masterTable = $find(radGridId).get_masterTableView(); |
| var result = masterTable.exportToExcel(); |
| alert (result); |
| } |
The alert shows me that masterTable.exportToExcel() returns False.
Any idea what I might be doing wrong?
Many Thanks
Eric