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

RadGrid ClientEvents OnCommand property appears to break RadGrid's paging

5 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gregg
Top achievements
Rank 1
Gregg asked on 10 Mar 2009, 08:57 PM
Adding the ClientEvents OnCommand property to the RadGrid appears to break the Grid's paging functionality.

I have:

<script type="text/javascript">
    function TestFunction() {
    } 
</script>

<telerik:RadGrid ID="RadGrid1" runat="server"
    OnNeedDataSource="RadGrid1_NeedDataSource"
    AllowSorting="true"
    AutoGenerateColumns="false"
    AllowPaging="true"
    PageSize="100"
    EnableEmbeddedSkins="false"
    Skin="Web20">
    <PagerStyle Mode="NextPrevAndNumeric" PrevPageImageUrl="PagingPrev.gif" NextPageImageUrl="PagingNext.gif" FirstPageImageUrl="PagingFirst.gif" LastPageImageUrl="PagingLast.gif"></PagerStyle>
    <ClientSettings>
 <ClientEvents OnCommand="TestFunction" />
 <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="300px" />
    </ClientSettings> ...

When <ClientEvents OnCommand="TestFunction" /> is declared, the paging controls in the grid look and act weird: For instance, in paging controls "Displaying page X of X, items X to X of X" all of the Xs become grayed out. Also, the "Change page: < 1, 2, 3 >" controls don't change appearance to indicate the page you are on.  However, the paging functionality still works.

When I remove the <ClientEvents OnCommand="TestFunction" /> declaration, the grid's paging goes back to normal.

Is this a bug?

5 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 12 Mar 2009, 01:51 PM
Hi Gregg,

Indeed, this is a bug in the 13.14 version of the controls.

Please, download the new Q1 release, which includes a fix to the problem.

Regards,
Tsvetoslav
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
Sridhar Nathani
Top achievements
Rank 1
answered on 20 Sep 2010, 03:45 AM
What is the fix? and where is the example?
0
Tsvetina
Telerik team
answered on 20 Sep 2010, 03:50 PM
Hello Sridhar,

The fix is an internal fix in the Telerik.Web.UI.dll holding the new version of RadControls. You can see that the client-side OnCommand event does not break the paging functionality in the latest version of RadControls in the sample project which I am attaching to this post.

Regards,
Tsvetina
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
Anthony DiNatale
Top achievements
Rank 1
answered on 08 Nov 2010, 10:01 PM
This does break paging if you try to cancel the event.  Replace the alert("OnCommand fired"); in your sample with

eventArgs.set_cancel(

true); and you will see that not only does the pagesize dropdown change (although the event was cancelled and should remain on the previous selection) but the page number buttons disappear as well.  Please let me know how to resolve this issue.

0
Tsvetina
Telerik team
answered on 11 Nov 2010, 01:48 PM
Hello Anthony,

This happens because the OnCommand client-side event is designed mostly to work in favor of client-side binding. That is why a client-side page size change is detected before the command is passed to the server and the pager is updated.

If you want to prevent the page size combo from doing any changes, you can wire its SelectedIndexChanging client-side event and cancel it (so the pager remains intact). Here is how you can access it in the ItemCreated event of RadGrid:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
   if (e.Item is GridPagerItem)
   {
     RadComboBox comboPageSize = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
   }
}


All the best,
Tsvetina
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
Gregg
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Sridhar Nathani
Top achievements
Rank 1
Tsvetina
Telerik team
Anthony DiNatale
Top achievements
Rank 1
Share this question
or