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

[Solved] Client Side delete gives wrong row index

1 Answer 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pabanas
Top achievements
Rank 1
Pabanas asked on 19 May 2009, 12:51 AM

 Please add  the following code to ondelete event to display args.get_itemIndexHierarchical() value in the example supplied by Telerick online demo   " radcontrols_aspnetajax/Grid/Examples/Client/ClientDelete/DefaultCS.aspx


 <script type="text/javascript">

            function Rowdeleting(sender, args) {
                var row_no = args.get_itemIndexHierarchical();
                alert(row_no);
                var row = sender.get_masterTableView().get_dataItems()[row_no];
                alert(row);
            }

          <ClientSettings  AllowKeyboardNavigation="True" >
                            <Selecting AllowRowSelect="True"  />
<ClientEvents  OnRowDeleting="Rowdeleting"  ></ClientEvents>
                         </ClientSettings>

           Now run the code and delete any row in the middle of the grid it will show the row index and will work fine .

           Now delete the last row in the grid it will  show wrong row index and so the row object will be empty .

           How do i get the correct row index after client side delete ?


 





1 Answer, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 21 May 2009, 12:44 PM
Hi Pabanas ,

As you may know you should not use item's indexHierarchical as index of dataItems client-side collection. Although they may seems identical in some cases, this is not always true and should be avoided. Instead in your case you should use the elements id which is passed with event's arguments and directly locate the item's client-side object, similar to the following:

           function Rowdeleting(sender, args) {                  
                 sender.get_masterTableView().get_dataItems()  
                alert($find(args.get_id())) // get item's object  
            } 

Best regards,
Sebastian
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.
Tags
Grid
Asked by
Pabanas
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or