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

Ajaxmanger cause Radgrid NeedDataSource?

5 Answers 241 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
James Shelton Agar
Top achievements
Rank 2
James Shelton Agar asked on 08 Aug 2008, 01:20 AM
I have following controled placed
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"   
        EnableHistory="True" EnablePageHeadUpdate="False">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadAjaxManager1" /> 
                    <telerik:AjaxUpdatedControl ControlID="ToolListing" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
        <script type="text/javascript">  
            function RowSelected(sender, eventArgs) {  
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");  
                ajaxManager.ajaxRequest('ROWSELECT:' + eventArgs.get_itemIndexHierarchical());  
            }  
        </script> 
    </telerik:RadCodeBlock> 
<telerik:RadAjaxPanel ID="PnlContent" runat="server" EnablePageHeadUpdate="False" EnableHistory="True">  
<telerik:RadToolBar ID="ToolListing" runat="server">  
</telerik:RadToolBar> 
<telerik:RadGrid ID="AListingsGrid">  
<ClientSettings AllowKeyboardNavigation="True" EnableRowHoverStyle="True" EnablePostBackOnRowClick="False" 
    ClientEvents-OnRowSelected="RowSelected">  
<Selecting AllowRowSelect="True" /> 
<Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
<Resizing AllowColumnResize="True" EnableRealTimeResize="True" /> 
</ClientSettings> 
</telerik:RadGrid> 
</telerik:RadAjaxPanel> 

it's a perfromance issue when user call ajaxmanager though javascript
page_load is triggered, with Ispostback =false and ListingGrid_NeedDataSource is triggered
so bascially it caused user to reload the data though ajax event....

anyway, i don't want to use the builtin Grid Selectedindexchanged event since it doesn't fire on drag-to-select

5 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 08 Aug 2008, 06:39 AM
Hi James,

This sounds like a serious problem and I'd like to dig into it further. Firstly, a couple of notes concerning the pasted code:

  • I see the AJAX Manager set as updated control. Can you please share why you need this?
  • I can't see the Grid set as updated control. Instead, you've set the Toolbar as updated. Can you please share which control do you update on the server? Posting your code-behind would help us get better impression on what's there on your end.
  • My suggestion is to avoid using both the AJAX Manager and the AJAX Panel at the same scenario. The AJAX Panel is designed for simple scenarios only while you can AJAXify any complex scenario with the help of RadAjaxManager. In this case, you can replace the AJAX Panel with the ASP:Panel for example and add Panel -> Panel AJAX Manager setting.
  • Please, make sure you work with the latest 2008.2.723 version there. We've addressed a similar problem officially with the latest release.

Looking forward to hearing from you.

All the best,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James Shelton Agar
Top achievements
Rank 2
answered on 11 Aug 2008, 05:40 AM

Hi, thank you for your reply!
This is indeed, a serious problem to harm the overall performance of the project.

I have try to make things clear a bit now, and here's the code (using latest 2008.2.723 version here)

driver.aspx

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="driver.aspx.vb" Inherits="AgentLive.driver" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
    </telerik:RadScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="AListingsGrid" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
 
        <script type="text/javascript">  
            function RowSelected(sender, eventArgs) {  
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");  
                ajaxManager.ajaxRequest('ROWSELECT:' + eventArgs.get_itemIndexHierarchical());  
            }  
 
            function RowDeselected(sender, eventArgs) {  
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");  
                ajaxManager.ajaxRequest('ROWDESELECT:' + eventArgs.get_itemIndexHierarchical());  
            }  
        </script> 
 
    </telerik:RadCodeBlock> 
    <telerik:RadGrid ID="AListingsGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
        GridLines="None" Skin="Vista" AllowSorting="True" Height="500px" PageSize="50" 
        AllowMultiRowSelection="True" ShowStatusBar="True">  
        <PagerStyle Mode="NextPrevAndNumeric" /> 
        <MasterTableView> 
            <SortExpressions> 
                <telerik:GridSortExpression FieldName="Href_no" SortOrder="Ascending" /> 
            </SortExpressions> 
            <RowIndicatorColumn Visible="False">  
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn Visible="False" Resizable="False">  
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridClientSelectColumn UniqueName="TagChecked">  
                    <HeaderStyle Width="20px" /> 
                </telerik:GridClientSelectColumn> 
                <telerik:GridBoundColumn DataField="Href_no" HeaderText="Ref" UniqueName="Ref">  
                    <HeaderStyle Width="70px" Wrap="False" /> 
                    <ItemStyle Width="70px" Wrap="False" /> 
                </telerik:GridBoundColumn> 
            </Columns> 
            <EditFormSettings> 
                <PopUpSettings ScrollBars="None"></PopUpSettings> 
            </EditFormSettings> 
        </MasterTableView> 
        <ClientSettings AllowKeyboardNavigation="True" EnableRowHoverStyle="True" ClientEvents-OnRowSelected="RowSelected" 
            ClientEvents-OnRowDeselected="RowDeselected">  
            <Selecting AllowRowSelect="True" /> 
            <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
            <Resizing AllowColumnResize="True" EnableRealTimeResize="True" /> 
        </ClientSettings> 
        <FilterMenu Skin="Vista" EnableTheming="True">  
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </FilterMenu> 
        <StatusBarSettings LoadingText="" /> 
    </telerik:RadGrid> 
    </form> 
</body> 
</html> 
 

driver.aspx.vb
Imports System.Reflection  
Imports System.Data  
Imports Telerik.Web.UI  
Imports System.Threading  
Imports System.IO  
 
Partial Public Class driver  
    Inherits System.Web.UI.Page  
 
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest  
        'something's happened  
        MsgBox(e.Argument)  
    End Sub  
 
    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles AListingsGrid.NeedDataSource  
        Dim officeD As New OfficeData  
        AListingsGrid.DataSource = aOffice.InfoListings 'Get datas here  
    End Sub  
 
    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load  
        If Not Me.IsPostBack Then  
            MsgBox("apostback has occured")  
        End If  
    End Sub  
End Class 

I have found sometimes, it caused the postback and GridRebindReason.InitialLoad
it will postback and call GridRebindReason.InitialLoad  (needdatasource), every time when user "drag to select" or when ajaxmanager does not update the specific radgrid control or when select it 3-4 times (which is really strange).

I just try to achive a simple task here but this bug actually stopped me from going any further...

alternativily i could use the "Enablepostbackonrowselect" and seletedIndexchanged event, but again, it does not fire on drag-to-select

thanx

0
Konstantin Petkov
Telerik team
answered on 12 Aug 2008, 07:43 AM
Hello James,

It seems I did not understand properly your scenario or I'm still missing something.

I created a similar demo to the one you pasted. Since you trigger AJAX requests on each selection/deselection from the Grid, the request is passed to the server and you get update of the Grid (which is expected as it is set as updated in the AJAX settings). I've used the following code to simulate that:

   <telerik:RadScriptManager ID="RadScriptManager1" runat="server" OutputCompression="AutoDetect">   
    </telerik:RadScriptManager>  
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">   
        <AjaxSettings>  
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">   
                <UpdatedControls>  
                    <telerik:AjaxUpdatedControl ControlID="AListingsGrid" />  
                </UpdatedControls>  
            </telerik:AjaxSetting>  
        </AjaxSettings>  
    </telerik:RadAjaxManager>  
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">   
  
        <script type="text/javascript">   
            function RowSelected(sender, eventArgs) {   
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");   
                ajaxManager.ajaxRequest('ROWSELECT:' + eventArgs.get_itemIndexHierarchical());   
            }   
  
            function RowDeselected(sender, eventArgs) {   
                var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");   
                ajaxManager.ajaxRequest('ROWDESELECT:' + eventArgs.get_itemIndexHierarchical());   
            }   
        </script>  
  
    </telerik:RadCodeBlock>  
    <telerik:RadGrid ID="AListingsGrid" runat="server" AllowPaging="True" AutoGenerateColumns="False"  
        GridLines="None" Skin="Vista" AllowSorting="True" Height="500px" PageSize="50"  
        AllowMultiRowSelection="True" ShowStatusBar="True" OnNeedDataSource="AListingsGrid_NeedDataSource">   
        <PagerStyle Mode="NextPrevAndNumeric" />  
        <MasterTableView Width="100%">  
            <SortExpressions>  
                <telerik:GridSortExpression FieldName="Href_no" SortOrder="Ascending" />  
            </SortExpressions>  
            <RowIndicatorColumn Visible="False">   
                <HeaderStyle Width="20px"></HeaderStyle>  
            </RowIndicatorColumn>  
            <ExpandCollapseColumn Visible="False" Resizable="False">   
                <HeaderStyle Width="20px"></HeaderStyle>  
            </ExpandCollapseColumn>  
            <Columns>  
                <telerik:GridClientSelectColumn UniqueName="TagChecked">   
                    <HeaderStyle Width="20px" />  
                </telerik:GridClientSelectColumn>  
                <telerik:GridBoundColumn DataField="Href_no" HeaderText="Ref" UniqueName="Ref">   
                    <HeaderStyle Width="70px" Wrap="False" />  
                    <ItemStyle Width="70px" Wrap="False" />  
                </telerik:GridBoundColumn>  
            </Columns>  
            <EditFormSettings>  
                <PopUpSettings ScrollBars="None"></PopUpSettings>  
            </EditFormSettings>  
        </MasterTableView>  
        <ClientSettings AllowKeyboardNavigation="True" EnableRowHoverStyle="True" ClientEvents-OnRowSelected="RowSelected"  
            ClientEvents-OnRowDeselected="RowDeselected">   
            <Selecting AllowRowSelect="True" />  
            <Scrolling AllowScroll="True" UseStaticHeaders="True" />  
            <Resizing AllowColumnResize="True" EnableRealTimeResize="True" />  
        </ClientSettings>  
        <FilterMenu Skin="Vista" EnableTheming="True">   
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>  
        </FilterMenu>  
        <StatusBarSettings LoadingText="" />  
    </telerik:RadGrid>      

    private void Page_Load(object sender, System.EventArgs e) 
    { 
        if (RadAjaxManager1.IsAjaxRequest) 
        { 
            RadAjaxManager1.Alert("an AJAX request has occured"); 
        } 
    } 
 
    protected void AListingsGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) 
    { 
        DataTable table = new DataTable(); 
        DataColumn col = new DataColumn("Href_no"); 
        table.Columns.Add(col); 
 
        DataRow row = null
 
        for (int i = 0; i < 150; i++) 
        { 
            row = table.NewRow(); 
            row[col] = "Item" + i; 
            table.Rows.Add(row); 
        } 
 
        AListingsGrid.DataSource = table; 
    } 

Let us know if I'm missing something out.

Sincerely yours,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
James Shelton Agar
Top achievements
Rank 2
answered on 12 Aug 2008, 09:32 PM
yes, that's right, but i want to do a ajaxpostback without updating the grid.
remove
<telerik:AjaxUpdatedControl ControlID="AListingsGrid" />  
wouldn't work, it will still go back reload the grid with need datasource
0
Konstantin Petkov
Telerik team
answered on 15 Aug 2008, 08:34 AM
Hello James,

It seems I was mistaken, please excuse me about that.

I'm sending you the actual page I'm testing with. I'm testing with the latest Q2 2008 version labeled 2008.2.723, but I don't get the NeedDataSource fired on selection or drag to select of the Grid although the RadAjaxManager's AjaxRequest server-side event is fired. Can you please give it a try and modify it if necessary so that the problem can be replicated? You can either post the updated code here or use a support ticket to send the application. Or do you get the NeedDataSource fired when you just put the page into your project and run it?

Greetings,
Konstantin Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
James Shelton Agar
Top achievements
Rank 2
Answers by
Konstantin Petkov
Telerik team
James Shelton Agar
Top achievements
Rank 2
Share this question
or