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

Cancel Command on Insert Row

3 Answers 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shanthala Somashekar
Top achievements
Rank 1
Shanthala Somashekar asked on 19 Oct 2009, 03:44 PM
Hello,
 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.

if

 

(!grid.MasterTableView.IsItemInserted)

 

{

grid.MasterTableView.IsItemInserted =

true;

 

grid.Rebind();

}

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?')) {

 

args.set_cancel(

false);

 

}

 

else {

 

args.set_cancel(

true);

 

}

}

}

 

</script>

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

 

3 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 22 Oct 2009, 01:39 PM
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.

Kiara
0
Shanthala Somashekar
Top achievements
Rank 1
answered on 22 Oct 2009, 01:58 PM
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.

Thanks
0
Veli
Telerik team
answered on 27 Oct 2009, 12:39 PM
Hello Shanthala,

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

Sincerely yours,
Veli
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.
Tags
Grid
Asked by
Shanthala Somashekar
Top achievements
Rank 1
Answers by
Kiara
Top achievements
Rank 1
Shanthala Somashekar
Top achievements
Rank 1
Veli
Telerik team
Share this question
or