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

RadGrid, Ajax and Sharepoint

1 Answer 55 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Álvaro
Top achievements
Rank 1
Álvaro asked on 22 Jul 2013, 08:24 AM
Hi,

I have a Sharepoint webpart that contains a Radgrid control. This control doesn't work properly in my webpart. I've installed ASP.NET AJAX, I've followed this link "http://www.telerik.com/community/forums/sharepoint-2010/integrate-ajax-controls/telerik-ajax-issue-with-sharepoint-2010.aspx" and Telerik documentation, and the grid doesn't work. When I click in a page number of the grid, nothing happens, but if I click again, all page is reload and the page changes. If I debug the Javascript code of Sharepoint page with Internet Explorer debug, there is an error in the last line of this function, to assing "innerHTML" property, although "updatePanelElement" object exists:

function Sys$WebForms$PageRequestManager$_updatePanel(updatePanelElement, rendering) {
        for (var updatePanelID in this._scriptDisposes) {
            if (this._elementContains(updatePanelElement, document.getElementById(updatePanelID))) {
                var disposeScripts = this._scriptDisposes[updatePanelID];
                for (var i = 0, l = disposeScripts.length; i < l; i++) {
                    eval(disposeScripts[i]);
                }
                delete this._scriptDisposes[updatePanelID];
            }
        }
        this._destroyTree(updatePanelElement);
        updatePanelElement.innerHTML = rendering;
    }

This is the code of my webpart main class:

private RadAjaxManager mAjaxManager;
 
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
 
            Page.ClientScript.RegisterStartupScript(typeof(myWebPart), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
            if (this.Page.Form != null)
            {
                string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
                if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
                {
                    this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
                }
            }
 
            ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
            if (scriptManager == null)
            {
                scriptManager = new RadScriptManager();
                Page.Form.Controls.Add(scriptManager);
            }
 
            SetUpAjaxManagerOnPage();
 
            EnsureChildControls();
        }
 
 
        protected void SetUpAjaxManagerOnPage()
        {
            RadAjaxManager currentAjaxManager = RadAjaxManager.GetCurrent(Page);
 
            if (currentAjaxManager == null)
            {
                Page.Form.Controls.AddAt(0, AjaxManager);
                Page.Items.Add(typeof(RadAjaxManager), AjaxManager);
            }
        }
 
        protected virtual RadAjaxManager AjaxManager
        {
            get
            {
                if (mAjaxManager == null)
                {
                    mAjaxManager = RadAjaxManager.GetCurrent(Page);
 
                    if (mAjaxManager == null)
                    {
                        mAjaxManager = new RadAjaxManager() { ID = "RadAjaxManager1" };
                    }
                }
 
                return mAjaxManager;
            }
        }
 
        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
        }

The code behind of the webpart, in the "Load" method is:

protected void Page_Load(object sender, EventArgs e)
        {
            RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
            manager.EnableAJAX = true;
            manager.AjaxSettings.AddAjaxSetting(gvActuaciones, pnlGrid);
        }

In the ascx file, the RadGrid code is the following code:

<asp:Panel ID="pnlGrid" runat="server">
        <telerik:RadGrid ID="gvActuaciones" runat="server"
            OnNeedDataSource="gvActuaciones_NeedDataSource" AutoGenerateColumns="False"
            ShowStatusBar="True" AllowPaging="True" ShowFooter="True" PageSize="5">
            <ClientSettings>
                <Scrolling  AllowScroll="true" UseStaticHeaders="true"  SaveScrollPosition="true" ></Scrolling>
            </ClientSettings>
            <MasterTableView TableLayout="Fixed" >
                <Columns>
                    <telerik:GridTemplateColumn AllowFiltering="false" HeaderStyle-Width="60px" HeaderText="">
                        <ItemTemplate>
                            ...                    
                        </ItemTemplate>                                        
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn ...>
                   <telerik:GridBoundColumn ...>
                   ...
            </MasterTableView>
           </telerik:RadGrid>
</asp:Panel>

I don't know what can I do.
Thank you very much

1 Answer, 1 is accepted

Sort by
0
Álvaro
Top achievements
Rank 1
answered on 22 Jul 2013, 10:50 AM
I think I've found the problem.

RadGrid was inside a html table. I've seen this link http://forums.asp.net/t/1127512.aspx/1, and I've moved the RadGrid out of the table and suddlenly, everything works fine. I don't know if it's a bug of RadGrid or whether I wasn't using RadGrid correctly.

Cheers
Tags
Ajax
Asked by
Álvaro
Top achievements
Rank 1
Answers by
Álvaro
Top achievements
Rank 1
Share this question
or