Hi All,
I have an entirely code-behind (C#) RadGrid that is being used in a SharePoint web-part, and I would like to use a RadAjaxManager with it. Can anyone please tell me and/or point me in the right direction for implementing one?
Thanks,
Mark
I have an entirely code-behind (C#) RadGrid that is being used in a SharePoint web-part, and I would like to use a RadAjaxManager with it. Can anyone please tell me and/or point me in the right direction for implementing one?
Thanks,
Mark
3 Answers, 1 is accepted
0
Hello Mark,
Note that ajaxifying the telerik controls that are positioned within a user controls works somewhat differently from the scenario when they are loaded directly on a web form. In you case, you need to move the RadAjaxManager control to the web part class, create it there and add it to the Controls collection of the web part as follows:
Then in the OnLoad event of the web part, get the RadAjaxManager as follows:
and add your ajax settings programmatically. Beforehand, you should have the user control in the CreateChildControls method of the web part and there through FindControl you should retrieve the controls to ajaxify. Keep them in a private variable local to the web part class and use that in the OnLoad event to dynamically add the ajax settings.
Hope this information will prove helpful.
Regards,
Maria Ilieva
Telerik
Note that ajaxifying the telerik controls that are positioned within a user controls works somewhat differently from the scenario when they are loaded directly on a web form. In you case, you need to move the RadAjaxManager control to the web part class, create it there and add it to the Controls collection of the web part as follows:
private
RadAjaxManager _ajaxManager;
protected
override
void
OnInit(EventArgs e)
{
base
.OnInit(e);
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
(_ajaxManager ==
null
)
{
_ajaxManager = RadAjaxManager.GetCurrent(Page);
if
(_ajaxManager ==
null
)
{
_ajaxManager =
new
RadAjaxManager() { ID =
"RadAjaxManager1"
};
}
}
return
_ajaxManager;
}
}
Then in the OnLoad event of the web part, get the RadAjaxManager as follows:
RadAjaxManager _manager = RadAjaxManager.GetCurrent(Page);
and add your ajax settings programmatically. Beforehand, you should have the user control in the CreateChildControls method of the web part and there through FindControl you should retrieve the controls to ajaxify. Keep them in a private variable local to the web part class and use that in the OnLoad event to dynamically add the ajax settings.
Hope this information will prove helpful.
Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0

Mark
Top achievements
Rank 1
answered on 27 Feb 2014, 02:39 PM
Hi Maria!
Thanks for the reply. I attempted to implement this to the best of my abilities, although I do not fully understand what is meant by, "Beforehand, you should have the user control in the CreateChildControls method of the web part and there through FindControl you should retrieve the controls to ajaxify. Keep them in a private variable local to the web part class and use that in the OnLoad event to dynamically add the ajax settings."
Applying the RadAjaxManager appears to disable filtering and paging in the RadGrid. It appears to load just fine, but User interaction is limited.
Thanks,
Mark
Thanks for the reply. I attempted to implement this to the best of my abilities, although I do not fully understand what is meant by, "Beforehand, you should have the user control in the CreateChildControls method of the web part and there through FindControl you should retrieve the controls to ajaxify. Keep them in a private variable local to the web part class and use that in the OnLoad event to dynamically add the ajax settings."
Applying the RadAjaxManager appears to disable filtering and paging in the RadGrid. It appears to load just fine, but User interaction is limited.
Thanks,
Mark
0
Hello Mark,
By having the UserControl into the WebParts CreateChildControls method I meant:
As for the functionality problems, I suppose that some js error appear when you are trying to filter or sort the RadGrid control. Please open the browser console and verify if any error appear.
Regards,
Maria Ilieva
Telerik
By having the UserControl into the WebParts CreateChildControls method I meant:
public
class
MyWebPart : System.Web.UI.WebControls.WebPart.WebPart
{
protected
override
void
CreateChildControls()
{
base
.CreateChildControls();
MyUserControl myUserControl = (MyUserControl)Page.LoadControl(
"~/_controltemplates/MyWebPart/MyUserControl.ascx"
);
myUserControl.Web = SPContext.Current.Web;
myUserControl.TextColor =
this
.TextColor;
// Adds it to the controls collection of the Web Part
this
.Controls.Add(myUserControl);
}
}
As for the functionality problems, I suppose that some js error appear when you are trying to filter or sort the RadGrid control. Please open the browser console and verify if any error appear.
Regards,
Maria Ilieva
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.