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

Load grid content after page is loaded

5 Answers 632 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 05 Oct 2012, 09:32 AM
Hi!

I have a data heavy application where one page should display custom number of RadGrids, depending how many tables are specified in XML file.
If I populate all n RadGrids with data on Page Load event, the site takes about 70 seconds to display, so this is a no go. What I want to do is to populate only first grid and display all other grids with no data (or dummy empty table as data source) on page load.

I am using UserControl to generate grids form XML. This UserControl is then used on an aspx page that uses master page.

I have searched the web, I have search your forum, and there are two solutions I found that I tried to integrate and failed miserably:
  1. Using asp timer. This was a problem, because no matter how I set up my RadAjaxManagerProxy's AjaxSettings, timer kept calling Page Load event as well.
  2. Using javascript timer and then call ajax requests back to page to load data. However, RadAjaxManagerProxy doesn't have client side api, and I am reluctant to wirte code on Master page for a sake of one UserControl.

Any other suggestions?

5 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 10 Oct 2012, 07:04 AM
Hi,

Each time a postback or an Ajax call is made the page life-cycle is the same. That means the Page_Load event will be fired and the code in its event handler will be executed.

If you have many grid instances, you could try to use the NeedDataSource event to bind them, instead of using DataBind method on Page_Load. Thus the Grid will load the data only when it needs to, otherwise it will load the data from the ViewState.

Again with the NeedDataSource you could specify a different datasource on the initial load and depending on some condition you could set different datasource.

Give this approach a try and check whether you get the desired behavior.

Greetings,
Andrey
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Vlad
Top achievements
Rank 1
answered on 10 Oct 2012, 03:57 PM
Hi Andrey,

the problem is not in data source loading. The problem is that there is no way to execute a JS Ajax call to radgrid after the page is loaded. Well not if you are using RadAjaxManagerProxy anyway. There is AjaxRequest, but that can be only connected to RadAjaxManager, which is on master page and my RadAjaxManagerProxy is on user control on some other page.
0
Andrey
Telerik team
answered on 11 Oct 2012, 01:38 PM
Hi,

You could get the RadAjaxManager isntance, through the GetCurrent static method of the RadAjaxManager class. As a parameter to this method you pass a reference to the page on that you want to access the RadAjaxManager:

protected void Page_Load(object sender, EventArgs e)
{
    RadAjaxManager manager = RadAjaxManager.GetCurrent(Page) as RadAjaxManager;
}

With this approach you should be able to achieve your goal.

Kind regards,
Andrey
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Vlad
Top achievements
Rank 1
answered on 15 Oct 2012, 09:23 AM
The trick is not in obtaining RadAjaxManager. The trick is in OnAjaxRequest event handler, which can only be handled on the page where RadAjaxManager is located, which is on master page in my instance.
I would like to avoid writing code in master page that will handle something in user control that exists only on some xy site.
0
Andrey
Telerik team
answered on 16 Oct 2012, 12:03 PM
Hello,

There is no problem, once you have reference to the RadAjaxManager instance, you could hook the RequestStart event in the user control.

I have assembled a sample project that uses Content/Master pages, the approach with user controls is the same. Give the project a try and check that the RequestStart event is fired from the content page.

All the best,
Andrey
the Telerik team
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Vlad
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Vlad
Top achievements
Rank 1
Share this question
or