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

GridClientDeleteColumn fails on bottom row

4 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy Yoder
Top achievements
Rank 1
Jeremy Yoder asked on 06 Feb 2014, 04:42 AM

The datasource for my RadGrid is a simple datatable. The grid has a GridClientDeleteColumn object. When I click delete, I want to remove the row from the grid and delete the row from the datatable the grid is bound to via NeedDataSource. I'm using RadAjaxManager.

To do all this, I call a javascript function via OnRowDeleting. From there I get the row's unique key via eventArgs.getDataKeyValue and pass it to a server-side function that has a WebMethod attribute. It deletes the row from the datatable. (If this is not the simplest/best way, then please advise.)

Anyway, it works great!... unless I delete the bottom row in the grid. Then when the grid refreshes, I get this error...

JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Specified argument was out of the range of valid values.
Parameter name: ItemHierarchicalIndex

It's not a particular row, but always the bottom row. I know this because I can sort the row by various columns, but only when I delete the bottom row and it refreshes do I get the error.

While trying to debug, on a whim, I put this line first in my javascript function that OnRowDeleting calls...

eventArgs.set_cancel(true);

Now when I delete the bottom row, as expected, it does not remove the row from the grid. However, when the grid is refreshed, I don't get the error and the row is gone because it was indeed deleted from the table on server-side.

What's the problem? Why does everything work unless it's the bottom row? And again, if there's a simpler/better way in general to remove the grid row and delete it from the datatable, then please advise.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Feb 2014, 06:15 AM
Hi Jeremy Yoder,

An appropriate server-side approach would be to either

-> use Autogenerated Delete Column
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateDeleteColumn="true" >
 
or
-> use GridButtonColumn
<telerik:GridButtonColumn CommandName="Delete" Text="Delete">
</telerik:GridButtonColumn>

Please look into this demo for its working Grid - Manual CRUD Operations

Thanks,
Shinu
0
Jeremy Yoder
Top achievements
Rank 1
answered on 06 Feb 2014, 02:55 PM

I used the latter and that seems to work. Thanks.

Do you have a guess why I was getting the error with the method I used? I want to better understand RadGrid, and I can't see anything wrong with what I was doing.
0
Jeremy Yoder
Top achievements
Rank 1
answered on 07 Feb 2014, 11:20 PM

Hello? Any ideas?
0
Shinu
Top achievements
Rank 2
answered on 10 Feb 2014, 06:14 AM
Hi Jeremy Yoder,

Could you please try disabling the ajax of the AjaxManager by setting its EnablaAjax property to false and check if you receive any server errors? Thus we are sure that the problem comes from RadAjax. Based on the provided information it is hard to determine the exact cause for the error you are getting. Can you please provide me with the markup of the problematic page and any related JavaScript and/or server-side code?

Thanks,
Shinu
Tags
Grid
Asked by
Jeremy Yoder
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jeremy Yoder
Top achievements
Rank 1
Share this question
or