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

ExportToCSV() not working properly

0 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chong
Top achievements
Rank 1
Chong asked on 02 Jul 2012, 10:03 AM
Hello all,

I am trying to develop an application that allows user to search and filter through the whole list of reports and grabs the rows and data the user wants and then allowing the user to export to CSV for documentation, but it appears that when I use the function radGrid2.MasterTableView.ExportToCSV(); it doesnt seem to export, but instead it appears on the page itself. I have tried to bind another static radgrid, a pop up appears allowing user to save or open, subsequently i suspected that it could be due to the grid image or null cells that could cause the issue but it did not as i stripped them all off. It did not help at all still.

i have attached a screenshot of the output of the button click, instead a pop up that allows user to save or open file, it appears on the web application itself.
output csv

my code is as below:
 <telerik:RadGrid ID="RadGrid1" Width="100%" Height="100%" EnableEmbeddedSkins="false"
                Skin="PQWS" AllowPaging="True" runat="server" GridLines="None" CellSpacing="0"
                AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand"
                AllowSorting="true" OnSortCommand="RadGrid1_SortCommand" OnPageIndexChanged="RadGrid1_PageIndexChanged">
                <PagerStyle Mode="NextPrevAndNumeric" />
                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Selecting AllowRowSelect="True" />
                </ClientSettings>
                <ExportSettings>    
    <Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" FileExtension="TXT" EncloseDataWithQuotes="false" />
</ExportSettings>
                <MasterTableView Width="100%" AutoGenerateColumns="False" DataKeyNames="CRN" AllowMultiColumnSorting="true">
                    <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                    <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center"
                            HeaderText="1" UniqueName="New" AllowFiltering="false">
                            <ItemTemplate>
                                <asp:Image ID="HighLight_Image" runat="server" ImageUrl="~/_layouts/PQWS/images/Highlight.gif" AlternateText="AltText" />
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="5%" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" 
                            HeaderText="2" AllowFiltering="false" UniqueName="TrafficLight">
                            <ItemTemplate>
                                <asp:Image ID="TrafficLight_Image" runat="server" Visible="false" AlternateText="AltText"/>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="5%" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="ReadFlag" UniqueName="ReadFlag" Visible="FALSE" />
                        <telerik:GridBoundColumn HeaderText="" DataField="HoldingReplySent" UniqueName="HoldingReplySent"
                            Visible="FALSE" />
                        <telerik:GridBoundColumn DataField="CRN" HeaderText="CRN" UniqueName="CRN" HeaderStyle-Width="12%" ShowSortIcon="true" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif" />                        
                        <telerik:GridBoundColumn HeaderText="Name" DataField="Name" UniqueName="Name" ShowSortIcon="true" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif">
                            <HeaderStyle Width="15%" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Description" DataField="Description" UniqueName="CaseType"
                            ShowSortIcon="true" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif"/>
                        <telerik:GridBoundColumn HeaderText="Start Date" DataField="StartDate" DataFormatString="{0:dd-MMM-yyyy}" UniqueName="StartDate"
                            ShowSortIcon="true" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif">
                            <HeaderStyle HorizontalAlign="Center" Width="10%" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Closed Date" DataField="ClosedDate" DataFormatString="{0:dd-MMM-yyyy}" UniqueName="ClosedDate" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif">
                            <HeaderStyle HorizontalAlign="Center" Width="10%" />
                            <ItemStyle HorizontalAlign="Center" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Elapsed Day(s)/Case Turnaround Time" DataField="DaysPending"
                            UniqueName="DaysPending" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif">
                            <HeaderStyle HorizontalAlign="Center" Width="5%" />
                            <ItemStyle HorizontalAlign="Center" />
                            </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Department(s) Assigned" DataField="DepartmentsAssigned"
                            UniqueName="DepartmentAssigned" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif"/>
                        <telerik:GridBoundColumn HeaderText="Status" DataField="Status" UniqueName="Status" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif">
                            <HeaderStyle Width="15%" />
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="UploadedToPQL" UniqueName="UploadedToPQL" Visible="false"  SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif"/>                        
                        <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="100px"
                            HeaderText="Action" AllowFiltering="false" SortAscImageUrl="~/_layouts/PQWS/images/arr_up.gif" SortDescImageUrl="~/_layouts/PQWS/images/arr_dn.gif" UniqueName="Action">
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageUpload" Width="20" runat="server" ImageUrl="~/_layouts/PQWS/images/Upload.png"
                                    CommandName="Upload" AlternateText="AltText" />&nbsp;<asp:ImageButton ID="ImageClose" Width="20" runat="server" ImageUrl="~/_layouts/PQWS/images/Close.PNG"
                                        CommandName="Close" AlternateText="AltText"/>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" Width="8%" />
                            <ItemStyle HorizontalAlign="Center" />
                            <%--  <ItemStyle HorizontalAlign="Center" />--%>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Chong
Top achievements
Rank 1
Share this question
or