Radgrid Client Delete

7 posts, 0 answers
  1. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 28 Apr 2009 Link to this post

     

    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());  
                            }  
                        }  
                    }  

     

     

     

     

     

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Apr 2009 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 29 Apr 2009 Link to this post

    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.

     

                    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();  
                       }  
                    } 
  5. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 29 Apr 2009 Link to this post

    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
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Apr 2009 Link to this post

    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
  7. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 29 Apr 2009 Link to this post

    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
  8. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 04 May 2009 Link to this post

    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,

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017