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

[Solved] Grid Performance /Localization Issue

7 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Taran
Top achievements
Rank 1
Taran asked on 20 May 2009, 03:10 PM
Hi Telerik Team,

We have implemented the RadGrid header localization using Grid ItemCreated event(as per mentioned in your help documentation).But here we are facing major performance issues;reason being during binding of the Grid for every record, Grid Item event is getting invoked, so calling of this event for every record is very time consuming.

We are looking for an event where we can localize grid header at once only other than Item_Created or Column_Created Event to regain performance of the page.

Thanks,
Rajesh

7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 25 May 2009, 02:38 PM
Hello Taran,

To achieve your goal I will suggest you review this online help article devoted on this matter.

For further information about RadGrid's life-cycle you can refer to this help topic.

Best Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Taran
Top achievements
Rank 1
answered on 27 May 2009, 07:06 AM
Hello Team,

Thanks for our response. Appreciate the same.

We have used localizing for declarative columns but the issue is that RadGrid_ItemCreated event is invoked every time while creating headers and while binding / populating data as well. This implies that if we have 50,000 records then ItemCreated event will be invoked 50,000 times even if a IF condition is put in for validating if item being created is a header item or not. Same as explained in the example:

protected void RadGrid2_ItemCreated(object sender, GridItemEventArgs e)
{
       
if (e.Item is GridHeaderItem)
       {
          GridHeaderItem headerItem = e.Item
as GridHeaderItem;

          LinkButton button = headerItem[
"ContactName"].Controls[0] as LinkButton;
          button.Text =
"My customized contact name";
          
          button = headerItem[
"ContactTitle"].Controls[0] as LinkButton;
          button.Text =
"My customized contact title";

          button = headerItem[
"Address"].Controls[0] as LinkButton;
          button.Text =
"My customized address";
       }
}

Please refer the if statement in bold, even if this statement is also used then also this event will be invoked number of times equal to the number of rows.

This is causing performance issues at our end. Even if we think of implementing Load on demand and grid will load limited number of records but again "ItemCreated" will be executed for each data row causing performance bottleneck.
 
Per our understanding, there should be a separate event to created grid headers so that data rows and columns should not have any impact over the same.

Just for your information, we have implemented RADControls for the very first time in one of our critical and huge project as we were little apprehensive about effectiveness, coding effort and performance with RAD Controls. We are right now in first phase of development and if are unable to resolve these issue then we might need to go for someother 3rd party controls for implementation which will be huge loss for both of us.

Request you to please look into this ASAP to have an early solution.

Regards,
Taran Dhingra
+1 916 8308751
+91 9811067353
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 May 2009, 12:56 PM
Hello Taran,

You can try setting the customizing the HeaderButton text in the PreRender event as shown below:
c#:
 protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        GridHeaderItem headerItem = (GridHeaderItem)RadGrid1.MasterTableView.GetItems(GridItemType.Header)[0]; 
        LinkButton button = headerItem["ContactName"].Controls[0] as LinkButton; 
        button.Text = "My customized contact name"
    } 

Thanks
Shinu.
0
Georgi Krustev
Telerik team
answered on 29 May 2009, 03:13 PM
Hello Taran,

I will suggest you once again to review this online help article devoted on the localization of the grid.

The normal life-cycle of the RadGrid is to raise ItemCreated event for every created item. This is also the normal behavior of the MS GridView. Please examine this online help article for further information.

All the best,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Taran
Top achievements
Rank 1
answered on 02 Jun 2009, 04:16 AM
Hello Shinu,

Thanks for yur response, much appreciate the same.

The solution you provided worked and there is a major performance boost while loading the grid now.

Thanks again.

Regards,
Taran
0
Taran
Top achievements
Rank 1
answered on 29 Jun 2009, 08:09 AM
HI,

We are facing one more issue with mentioned implementation. 

aftre clicking on any pager item in grid; grid column header text is getting lost when we are dynamically assigning column header values on grid prerender event but it is working fine when we are doing same thing on grid item created event.

So, my query is  how we can dynamically populate grid header without using grid item created event. But it should work with paging also.

below is the code that we are using for dynamic column header.

protected

 

void RadGrid_PreRender(object sender, EventArgs e)

 

{

 

RadGrid _rgGrid = sender as RadGrid;

 

 

if (_rgGrid != null)

 

{

 

if (_rgGrid.MasterTableView.GetItems(GridItemType.Header) != null && _rgGrid.MasterTableView.GetItems(GridItemType.Header).Length > 0)

 

{

 

GridHeaderItem headerItem = _rgGrid.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;

 

 

if (_rgGrid.MasterTableView.GetItems(GridItemType.Header).Length > 0)

 

{

 

if (headerItem != null)

 

{

((

LinkButton)headerItem["Number1"].Controls[0]).Text = "Number1";

 

((

LinkButton)headerItem["Number2"].Controls[0]).Text = "Number2";

 

}

}

}

}

}

Thanks

0
Georgi Krustev
Telerik team
answered on 30 Jun 2009, 04:03 PM
Hello Taran,

To preserve dynamically added header text you will need add it on every post back. This means you should use ItemCreated event in order to achieve the required functionality.

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Taran
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Taran
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or