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

Radgrid in SEOPaging mode : OnItemCreated fires too much

3 Answers 47 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mab CV
Top achievements
Rank 1
Mab CV asked on 03 Aug 2010, 05:20 PM

Hi,
I created my own Radgrid class which inherits from the Telerik Radgrid.
In my class, I override the OnItemCreated sub in order to create a specific pager (after a clear with aGridPagerItem.PagerContentCell.Controls.Clear()) :

 

Protected Overrides Sub OnItemCreated(ByVal e As Telerik.Web.UI.GridItemEventArgs)
     MyBase.OnItemCreated(e)
     If TypeOf e.Item Is Telerik.Web.UI.GridPagerItem Then
        .............
     
End If
 End Sub

In my aspx, the property EnableSEOPaging is set to "true" and I ask only for the Bottom pager :
<PagerStyle EnableSEOPaging="true" Mode="NextPrevAndNumeric" SEOPagingQueryStringKey="pageindexes" Position="Bottom" />

The problem is that I enter the OnItemCreated 4 times :
  • 2 times for the non SEO default pager (header and footer) which is not rendered
  • 2 times for the SEO pager (header and footer) which is rendered

Questions:

  1. Why do the OnItemCreated fires for the not rendered default pager ? How can I check this code-behind (to avoid my specific treatment in this case) ?
  2. Why do the OnItemCreated fires for the header even if I explicitly defines Position="Bottom" ?

Thanks a lot.
Good day.
E. Mansion

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 06 Aug 2010, 11:03 AM
Hello Mab CV,

ItemCreated fires twice for the GridPagerItem - once for the top and bottom pager items, no matter that one of them may not be visible. ItemCreated can fire 4 times for the pager items if you rebind the grid on postback. As rebinding causes RadGrid to recreate its structure, its items collection is cleared and recreated, so the ItemCreated-ItemDataBound cycle for each item is repeated. On initial load, however, and provided RadGrid is properly bound, ItemCreated is fired once for each pager items, so you get a total of 2 event calls.

Finally, let me note that if you will be creating your custom pager item and you are not keeping any of the built-in pager controls, why not use the PagerTemplate directly:

<telerik:RadGrid>
    <MasterTableView>
        <PagerTemplate>
            Define your pager controls here
        </PagerTemplate>
    </MasterTableView>
</telerik:RadGrid>


Regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Mab CV
Top achievements
Rank 1
answered on 23 Aug 2010, 02:52 PM
Hello,
thanks for your response ... but you didn't answer to the point 1.
First, notice that the solution of using the PagerTemplate is not good in our situation, so we have to override the OnItemCreated sub.

So the context is:
we noticed that when we set EnableSEOPaging="true" the OnItemCreated fires twice :
  1. first time: it appears to be the default pager with "postback links". However, this pager is not visible... (i recognize this pager in debug mode)
  2. second time: the pager in SEO mode, it is the pager we need to transform

And the question is:
How to recognize the first call for the default not visible pager ? (in debug mode, i didn't find any property to be able to distinguish them and to apply the treatment only for the SEO pager).

I hope that this is more clear.
Thanks and good day !
E. Mansion

0
Accepted
Veli
Telerik team
answered on 24 Aug 2010, 08:46 AM
Hi Mab CV,

I think I answered both points at once. RadGrid, by default, fires ItemCreated for the pager item 2 times - once for the top pager and once for the bottom pager. This is what I am observing. If you are observing a different behavior, consider sending us some sample project in a regular support ticket. Thus, we can test the project, try to reproduce what you are getting and advise you further on your scenario.

To distinguish the differences between the regular pager item and the pager item in SEO-mode, you have to examine the control structure in it. For regular pager, the grid generates LinkButtons and submit Buttons for navigation. For the SEO-pager, the grid creates HyperLinks.

Regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mab CV
Top achievements
Rank 1
Answers by
Veli
Telerik team
Mab CV
Top achievements
Rank 1
Share this question
or