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

Export grid option inside grid problem.

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thunaivan
Top achievements
Rank 1
Thunaivan asked on 21 Feb 2009, 01:57 PM
Hi all

i have a issue relative to export to excel. i tried export to excel button outside the grid its working pretty.
but i want an example inside grid and functionality should work .so i approached with follwing methods
(Keeping radajaxpanel with ClientEvents-OnRequestStart outside grid)
<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" ClientEvents-OnRequestStart="conditionalPostback"
                                                                                            <telerik:RadGrid ID="grdAccounts" GridLines="Vertical" runat="server" Skin="WebBlue" 
                                                                                                Width="100%" PageSize="5" AutoGenerateColumns="False" AllowSorting="true" AllowPaging="true" 
                                                                                                OnNeedDataSource="grdAccounts_NeedDataSource" OnItemCommand="grdAccounts_ItemCommand" 
                                                                                                ClientSettings-Resizing-AllowColumnResize="true" ClientSettings-Resizing-EnableRealTimeResize="true" 
                                                                                                AllowMultiRowSelection="true" ClientSettings-Selecting-AllowRowSelect="true" 
                                                                                                AllowAutomaticInserts="true"
                                                                                                <PagerStyle Mode="NextPrevAndNumeric" /> 
                                                                                                <ExportSettings FileName="AccountsGrid" OpenInNewWindow="true" ExportOnlyData="true" 
                                                                                                    IgnorePaging="true"
                                                                                                </ExportSettings> 
                                                                                                <%--<ClientSettings><Scrolling ScrollHeight="100px" AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /></ClientSettings>--%> 
                                                                                                <MasterTableView Width="100%" DataKeyNames="pkid" HierarchyLoadMode="Client" HorizontalAlign="NotSet" 
                                                                                                    CommandItemDisplay="Top"
                                                                                                    <NoRecordsTemplate> 
                                                                                                        <asp:Label ID="lblAccountNoRecordmsg" runat="server" Text="No accounts available"></asp:Label> 
                                                                                                    </NoRecordsTemplate> 
                                                                                                    <SortExpressions> 
                                                                                                        <telerik:GridSortExpression FieldName="accountname"></telerik:GridSortExpression> 
                                                                                                    </SortExpressions> 
                                                                                                    <RowIndicatorColumn> 
                                                                                                        <HeaderStyle Width="20px" BackColor="White"></HeaderStyle> 
                                                                                                    </RowIndicatorColumn> 
                                                                                                    <ExpandCollapseColumn Visible="True"
                                                                                                        <HeaderStyle Width="20px"></HeaderStyle> 
                                                                                                    </ExpandCollapseColumn> 
                                                                                                    <Columns> 
                                                                                                        <telerik:GridBoundColumn Display="false" DataField="pkid" HeaderText="pkid" UniqueName="pkid"
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn DataField="accounttype" HeaderText=" Type" UniqueName="accounttype"
                                                                                                            <HeaderStyle Width="13%" HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn DataField="accountname" HeaderText=" Name" UniqueName="accountname"
                                                                                                            <HeaderStyle Width="13%" HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn DataFormatString="{0:##-#######}" DataField="taxid" HeaderText="Tax ID" 
                                                                                                            UniqueName="taxid"
                                                                                                            <HeaderStyle Width="10%" HorizontalAlign="Center" /> 
                                                                                                            <ItemStyle HorizontalAlign="Left" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn DataField="primarycontact" HeaderText="Contact" UniqueName="primarycontact"
                                                                                                            <HeaderStyle Width="29%" HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn Visible="false" DataField="isactive" HeaderText="isactive" 
                                                                                                            UniqueName="isactive"
                                                                                                            <HeaderStyle HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn Visible="false" DataField="accounttypeid" HeaderText="accounttypeid" 
                                                                                                            UniqueName="accounttypeid"
                                                                                                            <HeaderStyle HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn DataFormatString="{0:(###)###-####}" DataField="PhoneNo" 
                                                                                                            HeaderText="Phone" UniqueName="PhoneNo"
                                                                                                            <HeaderStyle Width="13%" HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                        <telerik:GridBoundColumn DataFormatString="{0:(###)###-####}" DataField="MobileNo" 
                                                                                                            HeaderText="Mobile" UniqueName="MobileNo"
                                                                                                            <HeaderStyle Width="13%" HorizontalAlign="Center" /> 
                                                                                                        </telerik:GridBoundColumn> 
                                                                                                         
                                                                                                        <telerik:GridTemplateColumn HeaderText="Delete" HeaderStyle-ForeColor="White" ItemStyle-Width="8%" 
                                                                                                            ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="8%" HeaderStyle-HorizontalAlign="Center"
                                                                                                            <ItemTemplate> 
                                                                                                                <asp:ImageButton CommandName="Delete" ImageAlign="Middle" runat="server" ID="Delbudget" 
                                                                                                                    OnClientClick="return ProgramDelete();" src="../App_Themes/images/DeleteGrid.gif" 
                                                                                                                    Height="14" Width="13" alt="Delete" /> 
                                                                                                            </ItemTemplate> 
                                                                                                        </telerik:GridTemplateColumn> 
                                                                                                    </Columns> 
                                                                                                    <EditFormSettings UserControlName="~\ProgramConfiguration\UserControls\AddProgramAccount.ascx" 
                                                                                                        EditFormType="WebUserControl"
                                                                                                        <EditColumn UniqueName="EditCommandColumn1"
                                                                                                        </EditColumn> 
                                                                                                    </EditFormSettings> 
                                                                                                    <CommandItemTemplate> 
                                                                                                        <div> 
                                                                                                            <table width="100%" border="0" cellpadding="0" cellspacing="0"
                                                                                                                <tr> 
                                                                                                                    <td align="left"
                                                                                                                        <asp:Image ID="imgadd" runat="server" Height="13" ImageUrl="~/App_Themes/images/add.gif" /> 
                                                                                                                        <asp:LinkButton OnClientClick="return ProgramAdd();" CommandName="InitInsert" ToolTip="Add" 
                                                                                                                            ID="lnkbtnadd" runat="server" ForeColor="black" Text="Link Account"></asp:LinkButton> 
                                                                                                                    </td> 
                                                                                                                    <td align="center"><asp:Image ID="imgexport" runat="server" Height="13" ImageUrl="~/App_Themes/images/Excel-16.gif"  /><asp:LinkButton CommandName="exportExcel" ID="exportGrid" Text="Export" runat="server"></asp:LinkButton></td
                                                                                                                    <td align="right"
                                                                                                                        <asp:Image ImageUrl="~/App_Themes/images/Refresh.gif" runat="server" ID="imgRefresh" /> 
                                                                                                                        <asp:LinkButton CommandName="Refresh" ToolTip="Refresh" ID="lnkRefresh" Text="Refresh" 
                                                                                                                            runat="server" ForeColor="Black"></asp:LinkButton> 
                                                                                                                    </td> 
                                                                                                                </tr> 
                                                                                                            </table> 
                                                                                                        </div> 
                                                                                                    </CommandItemTemplate> 
                                                                                                    <%--<CommandItemSettings AddNewRecordText="Link Account" AddNewRecordImageUrl="../App_Themes/images/add.gif" />--%> 
                                                                                                </MasterTableView> 
                                                                                                <HeaderStyle ForeColor="White"></HeaderStyle> 
                                                                                                <ClientSettings> 
                                                                                                </ClientSettings> 
                                                                                                <FilterMenu Skin="WebBlue" EnableTheming="True"
                                                                                                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                                                                                                </FilterMenu> 
                                                                                            </telerik:RadGrid> 
                                                                                            </telerik:RadAjaxPanel> 

By above  without page postback export to excel opening in new window . but if i click to add or
edit page is getting postback and usercontrol which i m expecting to open is opening but i don't want page
to postback.


if i keep radajaxpanel in between export link (mean inside <CommandItemTemplate>)

<telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" ClientEvents-OnRequestStart="conditionalPostback">
<asp:Image ID="imgexport" runat="server" Height="13" ImageUrl="~/App_Themes/images/Excel-16.gif"  />
<asp:LinkButton CommandName="exportExcel" ID="exportGrid" Text="Export" runat="server"></asp:LinkButton>
</telerik:RadAjaxPane>


export to excel link is getting postback and remaining add ,edit is working fine.

and i tried with triggers, due to control inside the radgrid not able to assign id for controlid.

How to approach any help from leads.

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 24 Feb 2009, 12:25 PM
Hi Thunaivan,

When exporting, you need to differentiate between the export command, and any other command(s), to cancel out the Ajax. This is demonstrated in the following article. The Ajax mechanism is disabled only when exporting, and works as expected for all other commands.
I hope this suggestion helps.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Thunaivan
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or