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

ClientEvents: OnCommand issue

2 Answers 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brindavan
Top achievements
Rank 1
Brindavan asked on 10 Mar 2009, 01:17 AM
Hi,

I addedcode in the Grid <ClientEvents> to call a javascript function. The javascript function is as below:
function RaiseCommand(sender,args)
{

    if(args.get_commandName()=='Page' || args.get_commandName()=='Sort')
    {
        if('<%= grdOrders.MasterTableView.IsItemInserted %>' == 'True')
        {
            if(confirm("Some of the data entered may be lost. Do you want to continue?"))
            {
                 args.set_cancel(false);
            }
            else
            {
                args.set_cancel(true);
            }
        }
    }
}

As seen from the above, this is to alert the user that a data will be lost in the InsertItem if the page is changed or sorted.

The issue is that, this function is called correctly and also the alert is displayed.
But let's say that there are just 2 pages in the grid and in the insertitem is on page 2 and I chose to navigate to page 1. When I click on 'Prev' icon the confirm message comes up and I cancel it i.e. choose not to navigate. Now when I want to navigate to Page 1, the pager doesnt work. The page navigates to page 1 when I click on 'Next' icon and not on 'Prev' icon. This is incorrect. Also the footer message is getting changed to Page 1 of 2 even in the event of I cancelling the Command.

Any pointers?

Brindavan

2 Answers, 1 is accepted

Sort by
0
Gregg
Top achievements
Rank 1
answered on 10 Mar 2009, 07:07 PM
I have a problem that may be related to the one Brindavan describes.

My pageable grid subscribes to a js function thru the ClientEvents OnCommand property:

<ClientEvents OnCommand="jsFunction" />

The jsFunction does nothing to the grid. Let's say it simply displays "Hello World" on the page.

When I subscribe to the function via <ClientEvents OnCommand="jsFunction" />, 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="jsFunction" /> declaration, the grid's paging goes back to normal.
0
Sebastian
Telerik team
answered on 11 Mar 2009, 09:00 AM
Hello guys,

Both issues with the RadGrid pager and OnCommand attached should be addressed in the Q1 2009 release of the product, expected later today or tomorrow. Please stand by for the next release of the control.

Kind regards,
Sebastian
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
Brindavan
Top achievements
Rank 1
Answers by
Gregg
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or