Cancel Command on Insert Row

4 posts, 0 answers
  1. Shanthala Somashekar
    Shanthala Somashekar avatar
    9 posts
    Member since:
    Jul 2009

    Posted 19 Oct 2009 Link to this post

     I have a dynamically built grid with in-place editing and insert row. The insert row is always available at top and I have the following code to do so.






    grid.MasterTableView.IsItemInserted =





    I have hooked up the OnCommand client event for a confirmation from user when they hit cancel on the row.
    grid.ClientSettings.ClientEvents.OnCommand = "RaiseCommand";



    <script type="text/javascript">



    function RaiseCommand(sender, args) {



    if ( (args.get_commandName() == "CancelUpdate") || (args.get_commandName() == "CancelInsert")) {



    if (confirm('Are you sure you want to clear all of the answers for this row?')) {







    else {










    The problem is if the user confirms the cancel, the CancelCommand never gets fired for the Insert Row. It fires correctly for the Edit Row. I want to trap the CanceCommand to clear the insert row from any contents. Please help


  2. Kiara
    Kiara avatar
    309 posts
    Member since:
    Jul 2006

    Posted 22 Oct 2009 Link to this post

    Shanthala, what happens when you put breakpoints or inject debugger; keywords in your code - does the logic get executed as expected? Moreover, do you use the latest version of Telerik.Web.UI.dll (v2009.2.826)? The cancel command should work the same way both for edit and insert operation.

  3. Shanthala Somashekar
    Shanthala Somashekar avatar
    9 posts
    Member since:
    Jul 2009

    Posted 22 Oct 2009 Link to this post

    The debugger breaks on the client in the javascript function but the event never makes it to the server even if I don't cancel the event. The same works for edit row and the cancel command gets fired. Remember, my grid is built dynamically in Page.Init and added to a placeholder control on the page. And in the OnPreRender is when I make sure there is always an insert row. Maybe there is something going on because of that.
    My telerik version is 2009.1.402.35. I can try to move upto 2009.2.826 and see but I doubt that will resolve the issue.

    As a workaround I have triggered a postback from the client side via an invisible button when the user clicks cancel on the insert row and handled it that way, but I would like to have my code cleaner and make this work.

  4. Veli
    Veli avatar
    2002 posts

    Posted 27 Oct 2009 Link to this post

    Hello Shanthala,

    Checked the behavior with both declarative and programmatic RadGrid. Everything seems to work OK. Attaching page for you to test.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top