Dear Support
I want to use the following js to delete a item from the radgrid. If the js fires the first time, it runs correctly. On the next item it bring up an error. But I don't know why. Must I rebind the grid or someting else?
function DeleteItem() |
{ |
var _rowIndex = parseInt(-1); |
_rowIndex = parseInt(document.getElementById("radGridClickedRowIndex").value); |
if (_rowIndex >= 0) |
{ |
var bResponse = window.confirm("Datensatz wirklich löschen?"); |
if (bResponse) |
{ |
var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); |
masterTable.deleteItem(masterTable.get_dataItems()[_rowIndex].get_element()); |
} |
} |
} |
6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 29 Apr 2009, 06:36 AM
Hi,
You don't have to rebind the Grid since it is a client side operation. Can you post the error that you are getting. And also how you are populating the hidden field(radGridClickedRowIndex) that you are using on the client side?
Shinu
You don't have to rebind the Grid since it is a client side operation. Can you post the error that you are getting. And also how you are populating the hidden field(radGridClickedRowIndex) that you are using on the client side?
Shinu
0
Christian
Top achievements
Rank 1
answered on 29 Apr 2009, 08:03 AM
Dear Shinu
here is the function to fill the hidden field. Its fired if someone used the context menu. No other way is possible to delete an item. The other probelm is, if an item is delete (on the first time its possible), i saw in the db that the row is away, but the grid shows it.anymore !!! Confused about!!
The error is, that Javascript runs into an unexspected error. Nothing more as a description.
here is the function to fill the hidden field. Its fired if someone used the context menu. No other way is possible to delete an item. The other probelm is, if an item is delete (on the first time its possible), i saw in the db that the row is away, but the grid shows it.anymore !!! Confused about!!
The error is, that Javascript runs into an unexspected error. Nothing more as a description.
function RowContextMenu(sender, eventArgs) |
{ |
var menu = $find("<%= RadMenu1.ClientID %>"); |
var evt = eventArgs.get_domEvent(); |
if (evt.target.tagName == "INPUT" || evt.target.tagName == "A") |
{ |
return; |
} |
var index = eventArgs.get_itemIndexHierarchical(); |
document.getElementById("radGridClickedRowIndex").value = index; |
sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true); |
menu.show(evt); |
evt.cancelBubble = true; |
evt.returnValue = false; |
if (evt.stopPropagation) |
{ |
evt.stopPropagation(); |
evt.preventDefault(); |
} |
} |
0
Christian
Top achievements
Rank 1
answered on 29 Apr 2009, 08:10 AM
Hi Again,
so the main probelm should be that the grid wouldn't refersh after the client delete is execueed.
I saw after the deletion that the grid shows a sandglass but after it the deleted item is in the gridm but away from the underlying sql db.
Regards
Chrsitian
so the main probelm should be that the grid wouldn't refersh after the client delete is execueed.
I saw after the deletion that the grid shows a sandglass but after it the deleted item is in the gridm but away from the underlying sql db.
Regards
Chrsitian
0
Shinu
Top achievements
Rank 2
answered on 29 Apr 2009, 11:12 AM
Hi Christian,
I have tried the same code on my end and it is working fine. But I am using AdvanceDataBinding techniques which will automatically rebind the Grid just after the delete operation. I guess you are populating the Grid using simple databinding methods(calling DataBind()). If so try binding the Grid in the NeedDataSource event.
Shinu
I have tried the same code on my end and it is working fine. But I am using AdvanceDataBinding techniques which will automatically rebind the Grid just after the delete operation. I guess you are populating the Grid using simple databinding methods(calling DataBind()). If so try binding the Grid in the NeedDataSource event.
Shinu
0
Christian
Top achievements
Rank 1
answered on 29 Apr 2009, 11:44 AM
Hi Shinu,
First of all thanks for investigation.
To bound data I use a objectdatasource to populate data.
Also I reed in the helpd file the following:
Important: You should never call the Rebind() method in a NeedDataSource event handler.You should never call DataBind() as well when using advanced data-binding through NeedDataSource. For MS GridView-like data-binding see Simple Data-binding.
So cann you explain me on how I can resolve the problem.
Thanks alot
Christian
First of all thanks for investigation.
To bound data I use a objectdatasource to populate data.
Also I reed in the helpd file the following:
Important: You should never call the Rebind() method in a NeedDataSource event handler.You should never call DataBind() as well when using advanced data-binding through NeedDataSource. For MS GridView-like data-binding see Simple Data-binding.
So cann you explain me on how I can resolve the problem.
Thanks alot
Christian
0
Hi Uwe,
To progress in our investigation, I suggest you prepare a stripped working version of your project, demonstrating the erroneous behavior, and send it enclosed to a regular support ticket. We will examine it locally and will get back to you with our findings.
Kind regards,
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.