This is a migrated thread and some comments may be shown as answers.

[Solved] Problem with Client Export to Excel

2 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 28 Sep 2009, 12:33 PM
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
    <asp:Button ID="btnExportExcelClient" runat="server" Text="btnExportExcelClient" 
      OnClientClick="javascript:ExportToExcel();return false;" /> 
and the javascript below
        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


2 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 28 Sep 2009, 02:24 PM
Have you checked to see if your masterTable variable is not null? Perhaps the issue lies in the way you get the masterTableView (only difference I can see between your two implementations).
0
Eric
Top achievements
Rank 1
answered on 28 Sep 2009, 02:29 PM
Yes, it looks fine that far.
It fires the method which returns false.
I can't see any visible error other than a postback is performed while my button OnClick() contains a "return false;"
Tags
Grid
Asked by
Eric
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Eric
Top achievements
Rank 1
Share this question
or