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

Exporting to Excel get a error in your java script

1 Answer 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 02 Nov 2011, 01:24 PM
          <telerik:RadGrid AutoGenerateColumns="False" ID="xgrdApprovedAuths" AllowSorting="True"
              OnSortCommand="xgrdApprovedAuths_SortCommand" OnNeedDataSource="xgrdApprovedAuths_NeedDataSource"
              Height="200px" Width="9in" runat="server" CellSpacing="0">
              <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" />
                  <mastertableview tablelayout="Auto" width="100%" allownaturalsort="false">
                  <Columns>
                      <telerik:GridBoundColumn HeaderText="Status" DataField="ApprovalStatus" UniqueName="ApprovalStatus"
                          SortExpression="ApprovalStatus" HeaderStyle-VerticalAlign="Bottom" HeaderStyle-HorizontalAlign="Center"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle HorizontalAlign="Center" VerticalAlign="Bottom" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="AuthID" DataField="AuthID" UniqueName="AuthID"
                          SortExpression="AuthID" Visible="False" HeaderStyle-VerticalAlign="Bottom" ShowSortIcon="False"
                          ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Auth Number" DataField="AuthNumber" UniqueName="AuthNumber"
                          SortExpression="AuthNumber" HeaderStyle-VerticalAlign="Bottom" HeaderStyle-HorizontalAlign="Center"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle HorizontalAlign="Center" VerticalAlign="Bottom" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Auth Adj #" DataField="AuthAmendment" UniqueName="AuthAmendment"
                          SortExpression="AuthAmendment" ItemStyle-Wrap="False" HeaderStyle-VerticalAlign="Bottom"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False"
                          HeaderStyle-HorizontalAlign="Center">
                          <HeaderStyle HorizontalAlign="Center" VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Originator" DataField="CreatedBy" UniqueName="CreatedBy"
                          SortExpression="CreatedBy" ItemStyle-Wrap="False" HeaderStyle-VerticalAlign="Bottom"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="MemberID" DataField="MemberID" UniqueName="MemberID"
                          SortExpression="MemberID" Visible="False" HeaderStyle-VerticalAlign="Bottom"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Member Name" DataField="Member Name" UniqueName="Member Name"
                          SortExpression="Member Name" ItemStyle-Wrap="False" HeaderStyle-VerticalAlign="Bottom"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Start Date" DataField="StartDate" UniqueName="StartDate"
                          SortExpression="StartDate" HeaderStyle-VerticalAlign="Bottom" DataType="System.DateTime"
                          ItemStyle-Wrap="False" DataFormatString="{0:MM/dd/yyyy}" ShowSortIcon="False"
                          ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="End Date" DataField="EndDate" UniqueName="EndDate"
                          SortExpression="EndDate" HeaderStyle-VerticalAlign="Bottom" DataType="System.DateTime"
                          ItemStyle-Wrap="False" DataFormatString="{0:MM/dd/yyyy}" ShowSortIcon="False"
                          ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Max Units" DataField="MaxUnits" UniqueName="MaxUnits"
                          SortExpression="MaxUnits" HeaderStyle-VerticalAlign="Bottom" ItemStyle-Wrap="False"
                          DataType="System.Int32" DataFormatString="{0:###,##0}" ItemStyle-HorizontalAlign="Right"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False"
                          HeaderStyle-HorizontalAlign="Center">
                          <HeaderStyle HorizontalAlign="Center" VerticalAlign="Bottom" />
                          <ItemStyle HorizontalAlign="Right" Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Units Used" DataField="Units Used" UniqueName="Units Used"
                          SortExpression="Units Used" HeaderStyle-VerticalAlign="Bottom" DataType="System.Int32"
                          ItemStyle-Wrap="False" DataFormatString="{0:###,##0}" ItemStyle-HorizontalAlign="Right"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False"
                          HeaderStyle-HorizontalAlign="Center">
                          <HeaderStyle HorizontalAlign="Center" VerticalAlign="Bottom" />
                          <ItemStyle HorizontalAlign="Right" Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Division" DataField="Division" UniqueName="Division"
                          SortExpression="Division" HeaderStyle-VerticalAlign="Bottom" ItemStyle-Wrap="False"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False"
                          ItemStyle-HorizontalAlign="Center">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle HorizontalAlign="Center" Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Service Description" DataField="Service Description"
                          UniqueName="Service Description" SortExpression="Service Description" AutoPostBackOnFilter="true"
                          CurrentFilterFunction="Contains" HeaderStyle-VerticalAlign="Bottom" ShowSortIcon="False"
                          ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False" ItemStyle-Wrap="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                      <telerik:GridBoundColumn HeaderText="Reject Reason" DataField="RejectReason" UniqueName="RejectReason"
                          SortExpression="RejectReason" HeaderStyle-VerticalAlign="Bottom" ItemStyle-Wrap="False"
                          ShowSortIcon="False" ShowFilterIcon="False" ReadOnly="True" AllowFiltering="False">
                          <HeaderStyle VerticalAlign="Bottom" />
                          <ItemStyle Wrap="False" />
                      </telerik:GridBoundColumn>
                  </Columns>
              </mastertableview>
                  <clientsettings>
                  <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True">
                  </Scrolling>
              </clientsettings>
          </telerik:RadGrid>
          <asp:Button ID="cmdExport" runat="server" Text="Export to CSV File" OnClick="cmdExport_Click" />
 
  protected void cmdExport_Click(object sender, System.EventArgs e)
  {
      xgrdApprovedAuths.MasterTableView.ExportToExcel();
  }
 
  protected void xgrdApprovedAuths_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
  {
      try
      {
        clsAuthorizations auth = new clsAuthorizations(ss.dbConnect);
 
          DateTime FromDate;
          DateTime ToDate;
 
          if (txtProcessedStartDate.SelectedDate == null)
          {
              FromDate = System.DateTime.Now.AddYears(-50);
          }
          else
          {
              FromDate = txtProcessedStartDate.SelectedDate.Value;
          }
 
          if (txtProcessedEndDate.SelectedDate == null)
          {
              ToDate = System.DateTime.Now.AddYears(50);
          }
          else
          {
              ToDate = txtProcessedEndDate.SelectedDate.Value;
          }
 
          int ProviderID = ss.ProviderID;
 
          this.xgrdApprovedAuths.DataSource = auth.GetViewOnlyApprovedAuths(ProviderID, FromDate, ToDate, cboProcessedStatus.SelectedItem.Text, cboProcessedDivision.SelectedItem.Text, ss.listDivisionString);
          //this.xgrdApprovedAuths.DataBind();
 
   this.updApprovedAuths.Update();
}
   catch (Exception ex)
      {
          clsPortalErrorLog err = new clsPortalErrorLog(ss.dbConnect);
          err.LogError(ex.ToString(), User.Identity.Name, "AuthsMain.aspx", "BindApprovedAuths");
      }
  }
Using the following code I get error in the ScriptResource tab showing your java script.


I'm using Telerek version Q1 2011 with Visual Studio 2008.

I'm trying to export the grid to Excel.

 

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 02 Nov 2011, 03:48 PM
Hello John,

Have you ajaxified your page?
Please examine the Export from Ajaxified Grid to see how to temporarily disable the AJAX.

I hope this helps.

Regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or