Trying to get simple export to work

5 posts, 1 answers
  1. Darren
    Darren avatar
    14 posts
    Member since:
    Sep 2012

    Posted 31 Jul 2012 Link to this post

    Hi guys. I'm just trying to get the simple export feature to work. I like the demo sample here (Export Demo) where the grid has the export buttons built in. I was able to get the buttons to show up in the grid, however, when they are clicked on, nothing happens. (Well, the data seems to be refreshed against the object data source, which isn't what I want to happen...but I guess that's a separate issue) I've tried it in two different browsers and it doesn't seem to be blocked by pop-up blockers. Is there something I'm missing?

    Thanks!

            <telerik:RadGrid ID="grdEvals" runat="server" Width="720px" CellSpacing="0"
                DataSourceID="odsEvals" GridLines="None"
                onselectedindexchanged="grdEvals_SelectedIndexChanged" AllowPaging="True"
                AllowSorting="True" ShowGroupPanel="True" PageSize="20"
                ShowStatusBar="True"  >
                <ExportSettings IgnorePaging="True" >
                </ExportSettings>
                <ClientSettings EnablePostBackOnRowClick="True" AllowDragToGroup="True">
                    <Selecting AllowRowSelect="True" />
                </ClientSettings>
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="odsEvals"  CommandItemDisplay="Top" >
    <CommandItemSettings ExportToPdfText="Export to PDF" ShowExportToCsvButton="True"
            ShowExportToExcelButton="True" ShowExportToPdfButton="True"
            ShowExportToWordButton="True" ShowAddNewRecordButton="False"
            ShowRefreshButton="False"></CommandItemSettings>
     
    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </RowIndicatorColumn>
     
    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
    <HeaderStyle Width="20px"></HeaderStyle>
    </ExpandCollapseColumn>
     
        <Columns>
            <telerik:GridBoundColumn DataField="ID" DataType="System.Int32"
                FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True"  Visible="false"
                SortExpression="ID" UniqueName="ID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="EmployeeID"
                FilterControlAltText="Filter EmployeeID column" HeaderText="Employee ID"
                SortExpression="EmployeeID" UniqueName="EmployeeID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="EmployeeName"
                FilterControlAltText="Filter EmployeeName column" HeaderText="Employee Name"
                SortExpression="EmployeeName" UniqueName="EmployeeName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="DateCompleted" DataType="System.DateTime"
                FilterControlAltText="Filter DateCompleted column" HeaderText="Completed"
                SortExpression="DateCompleted" UniqueName="DateCompleted">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="CoreValueNos" DataType="System.Int32"
                FilterControlAltText="Filter CoreValueNos column" HeaderText="Core Value No's"
                SortExpression="CoreValueNos" UniqueName="CoreValueNos">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="OtherNos" DataType="System.Int32"
                FilterControlAltText="Filter OtherNos column" HeaderText="Other No's"
                SortExpression="OtherNos" UniqueName="OtherNos">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="EmployeeCostCenter"
                FilterControlAltText="Filter EmployeeCostCenter column"
                HeaderText="Cost Center" SortExpression="EmployeeCostCenter"
                UniqueName="EmployeeCostCenter">
            </telerik:GridBoundColumn>
        </Columns>
     
    <EditFormSettings>
    <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
    </EditFormSettings>
    </MasterTableView>
     
    <FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>

  2. Answer
    Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 31 Jul 2012 Link to this post

    Hello,

    Please make sure when you click on export button your updatepanel/Ajaxmanager is disabled.
    <script type="text/javascript">
            function onRequestStart(sender, args)
            {
                if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 ||
                        args.get_eventTarget().indexOf("ExportToWordButton") >= 0 ||
                        args.get_eventTarget().indexOf("ExportToCsvButton") >= 0)
                {
                    args.set_enableAjax(false);
                }
            }
        </script>
     
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <ClientEvents OnRequestStart="onRequestStart" />
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>


    Thanks,
    Jayesh Goyani
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Darren
    Darren avatar
    14 posts
    Member since:
    Sep 2012

    Posted 31 Jul 2012 Link to this post

    Wow, that worked. Thank you very much! :)

    I still have one issue: The grid binds to a SqlDataSource that selects almost all the data in the table. I have controls before the grid on the aspx page that allows the user to filter the data further. These filter fields I created directly update the sqldatasource on the autopostback. When I try to export the data, the exported document has all the data where it should have only what is showing in the grid. Does this make sense? Thanks again!
  5. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 31 Jul 2012 Link to this post

    Hello,

    Please set below property.

    RadGrid1.ExportSettings.IgnorePaging = true/false;

    Thanks,
    Jayesh Goyani
  6. Darren
    Darren avatar
    14 posts
    Member since:
    Sep 2012

    Posted 31 Jul 2012 Link to this post

    That worked! Thank you very much!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017