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

Problem with ajax and radgrid

4 Answers 167 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ignacio Ortuzar
Top achievements
Rank 1
Ignacio Ortuzar asked on 18 Mar 2010, 06:28 PM
Hi,

I want to use a grid with some command item template and one of these functionalities is Export to excel, but manually triggered.

The problem is that when I use an ajaxfied grid the export doesn't work, but if don't it woks fine.

Here is the aspx code:

<telerik:RadGrid runat="server" ID="rg_leads" AutoGenerateColumns="false" DataSourceID="ods_leads" AllowMultiRowSelection="true"  
            AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" OnItemCommand="rg_leads_ItemCommand"
            <HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> 
            <ClientSettings> 
                <Selecting AllowRowSelect="true" /> 
            </ClientSettings> 
            <ExportSettings IgnorePaging="true" OpenInNewWindow="false" ExportOnlyData="true" FileName="exporteddata.xls">  
            </ExportSettings> 
            <MasterTableView IsFilterItemExpanded="false" CommandItemDisplay="Top"
                <CommandItemTemplate> 
                    <telerik:RadToolBar runat="server" ID="rtb_toolBar"  
                        OnButtonClick="rtb_toolBar_ButtonClick"
                        <Items> 
                            <telerik:RadToolBarButton Text="Apply filter" CommandName="FilterRadGrid" ImageUrl="img/filter.png" ImagePosition="AboveText"  /> 
                            <telerik:RadToolBarButton IsSeparator="true"></telerik:RadToolBarButton> 
                            <telerik:RadToolBarButton ImageUrl="img/delete32.png" ImagePosition="AboveText" Text="Delete" CommandName="MassiveDelete"></telerik:RadToolBarButton> 
                            <telerik:RadToolBarDropDown ImagePosition="AboveText" ImageUrl="img/addToList32.png" Text="Add To List" OnDataBinding="DropDownDataBinding"
                                <Buttons> 
                                   <telerik:RadToolBarButton runat="server" CommandName="NewList2" > 
                                       <ItemTemplate> 
                                           <telerik:RadTextBox ID="rtb_newList" runat="server" Text="New List" onclick="this.value = ''" CssClass="textboxNewList"
                                           </telerik:RadTextBox> 
                                           <asp:ImageButton ID="ib_newList" runat="server" ImageUrl="img/add32.png" CommandName="NewList" CssClass="imageNewList" /> 
                                       </ItemTemplate> 
                                   </telerik:RadToolBarButton> 
                               </Buttons> 
                            </telerik:RadToolBarDropDown> 
                            <telerik:RadToolBarButton ImageUrl="img/export.png" Text="Export" CommandName="Export" ImagePosition="AboveText"></telerik:RadToolBarButton> 
                        </Items> 
                    </telerik:RadToolBar> 
                </CommandItemTemplate> 
                <Columns>...</Columns> 
           </MasterTableView> 
</telerik:RadGrid> 
 

And I've a Panel with all the content of the page called Panel1, so the ajax manager code looks like this.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="Panel1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 

How can I do to take arround the ajax call when I use the export button, but not when I use other tools like remove?

Thanks

4 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 18 Mar 2010, 07:25 PM
Hello Ignacio,

Please modify your code as shown below:
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server" ClientEvents-OnRequestStart="requestStart">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Panel1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Panel1" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<script type="text/javascript">
    function requestStart(sender, args)
    {
        if (args.get_eventTarget().indexOf("rtb_toolBar") >= 0)
            args.set_enableAjax(false)
    }
</script>

I also recommend you examine the following links:
Export from ajaxified grid
Exclude controls from ajaxifying
Export RadGrid content to Excel/Word/CSV/PDF with Ajax enabled

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Ignacio Ortuzar
Top achievements
Rank 1
answered on 18 Mar 2010, 08:06 PM
Daniel,

Thanks for your reply it was very helpfull and inspired me to get the solution.

Finally I add a new toolbar in the grid for the export, then I disable ajax behavior just for this toolbar, so the other functionalities works and looks fine.

Thanks again!
0
Smiely
Top achievements
Rank 1
answered on 06 Dec 2010, 04:52 PM
Hi,

I have a similar concern, I want to Exclude controls from ajaxifying. But I am passing a value to .aspx page. I don't have (sender, args) to control ajax.

function viewQualsClick(id) {
                window.open("RES_MQ_new.aspx?empid=" + id, "", "width=550,height=700,resizable=yes,scrollbars=yes");
            }
function ajaxRefresh() {
                var ram = $find("<%= RadAjaxManager.ClientID %>");
  
                ram.ajaxRequest("foo");
            }
How I do it?

Help...
0
Daniel
Telerik team
answered on 08 Dec 2010, 10:53 PM
Hello Smiely,

The easiest way to exclude a given control from ajaxifying (when using RadAjaxManager) is not to ajaxify it. That said, if you have an export button it will be best to keep it outside the updated controls - this way you won't have to add redundant code for excluding the button.
In some cases this is not possible - for example when the export control resides in RadGrid commanditem template. In this case you will have to fallback to the previous approach.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Ignacio Ortuzar
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ignacio Ortuzar
Top achievements
Rank 1
Smiely
Top achievements
Rank 1
Share this question
or