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

On client delete rowIndex not updated

2 Answers 65 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nils C.
Top achievements
Rank 1
Nils C. asked on 18 Oct 2012, 09:37 AM
Hi,

I am using a Radgrid with script services for the data binding.
For deleting a row, I implemented a GridClientDeleteColumn which fires a "Delete"-command on which I am deleting the clicked row via a script service. After deleting a row, the rowIndexes are actually not updated and I get some errors when I am deleting several rows after each other.

Here is my code:

   

function KontakthistorieGridCreated(ansprechpartnerid) {
 
    pms_neu.grid_service.get_history(window.location.hostname, ansprechpartnerid, kontakthistorieUpdateGrid);
 }
 
 function kontakthistorieUpdateGrid(result) {
     var tableView = $find("<%= rdg_historie.ClientID %>").get_masterTableView();
         tableView.set_dataSource(result);
         tableView.dataBind();
         tableView.set_virtualItemCount(result.length);
         adjust_pane_heights();
 }
 
 function OnCommand(sender, args) {
     //Die funktion kann ruhig leer sein, MUSS aber vorhanden sein (irgendwas mit Client-Object erstellen und so...)
     if (args.get_commandName() == "Delete") {
         var itemIndex = args.get_commandArgument();
         var history_id = sender.get_masterTableView().get_dataItems()[itemIndex].getDataKeyValue("id");
         pms_neu.grid_service.delete_history(window.location.hostname, history_id, history_delete_done);
 
         args.set_cancel(true);
     }
 }

There problem occurs because the commandArgument() isnot beeing updated after deleting the row and even not after I call the databind method again. Deleting itemIndex 0 will cause that the following first item has itemIndex 1 but it must be zero for fetching the right datatime.
 
var itemIndex = args.get_commandArgument();
var history_id = sender.get_masterTableView().get_dataItems()[itemIndex].getDataKeyValue("id");

Does anyone knows a solution for this?
I would really appreciate some help on this

Kind regards



2 Answers, 1 is accepted

Sort by
0
Accepted
Angel Petrov
Telerik team
answered on 22 Oct 2012, 03:56 PM
Hello Nils,

Thank you for contacting us.

You could workaround this issue by iterating through the items and extracting their indexes. In the attachments you could find the project that uses this approach and extracts always the desired index.

Greetings,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nils C.
Top achievements
Rank 1
answered on 23 Oct 2012, 02:22 PM
Thats it. Thanks!
Tags
Grid
Asked by
Nils C.
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Nils C.
Top achievements
Rank 1
Share this question
or