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

RadFilter & Export to Excel not working

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yogesh
Top achievements
Rank 1
Yogesh asked on 22 Mar 2012, 10:24 PM
Hi,

Previously had a control to export the grid to excel and was working fine.
Later on we found that we need to filter the records using the Radfilter control. So added the code as below:

<telerik:RadAjaxManager runat="server" ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadFilter1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadFilter1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" />
        <div class="filterDiv">
            <telerik:RadFilter runat="server" ID="RadFilter1" FilterContainerID="RadGrid1" ShowApplyButton="false" />
        </div>

 

                                    <CommandItemTemplate>                   
                    <telerik:RadToolBar runat="server" ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick">
                        <Items>
                            <telerik:RadToolBarButton Text="Apply filter" CommandName="FilterRadGrid" ImageUrl="<%#GetFilterIcon() %>"
                                ImagePosition="Right" />
                        </Items>
                    </telerik:RadToolBar>

                    </CommandItemTemplate>

 



Also made changes in the code behind file to fire the Filter command.

But now the Export to excel image button is not visible ......

Can anyone help ....

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Mar 2012, 06:51 AM
Hello Yogesh,

RadGrid does not show the Default command Item Buttons while using CommandItemTemplate. You need to explicitly add the required buttons in CommandItemTemplate with respective CommandName.

ASPX:
<CommandItemTemplate>
     <telerik:RadToolBar runat="server" ID="RadToolBar1">
      <Items>
       <telerik:RadToolBarButton Text="Apply filter" CommandName="FilterRadGrid" ImagePosition="Right" />
      </Items>
    </telerik:RadToolBar>
    <asp:Button ID="btnExport" runat="server" Text="Export" CommandName="ExportToExcel" />
</CommandItemTemplate>


While inspecting the code I noticed that you have ajaxified the Grid. Please note that we cannot export Ajaxified grid directly, need to disable ajax before exporting.

Javascript:
function onRequestStart(sender, args)
    {
        if (args.get_eventTarget().indexOf("btnExport") >= 0)
            args.set_enableAjax(false);
    }

Also take a look into the following documentation.
Export from Ajaxified Grid

Thanks,
Princy.
Tags
General Discussions
Asked by
Yogesh
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or