Disable Cell Drag and Drop

5 posts, 0 answers
  1. David
    David avatar
    278 posts
    Member since:
    Mar 2014

    Posted 19 Jul Link to this post

    I am trying to disable cell drag and drop between rows

    Here is my grid setup

     

      <telerik:RadGrid ID="grdResourceGrid" runat="server" 
                                AllowMultiRowEdit="true"  AllowAutomaticUpdates="true" 
                                OnNeedDataSource="OnNeedDataSource" 
                                OnItemUpdated="grdResourceGrid_ItemUpdated" 
                                OnUpdateCommand="grdResourceGrid_UpdateCommand"
                                OnItemDataBound="grdResourceGrid_ItemDataBound"
                                OnItemCreated="grdResourceGrid_ItemCreated" 
                                onclick="gridFocus(event)"                            
                                style="margin-top:0px;" 
                                ShowFooter="True"    
                                Skin="WebBlue" ShowGroupPanel="false" ShowStatusBar="True" GroupsDefaultExpanded="False" 
                                AllowSorting="false" AllowPaging="false" AllowFilteringByColumn="false" 
                                GridLines="None" AutoGenerateColumns="False">  
                    <GroupingSettings CaseSensitive="false"  />
                    <HeaderStyle BackColor="#6D8DAD" ForeColor="White" HorizontalAlign="Center" /> 

                    <ClientSettings AllowRowsDragDrop="false" AllowDragToGroup="false" Selecting-EnableDragToSelectRows="false">
                        <ClientEvents OnKeyPress="grdResourceGrid_OnKeyPress" /> 
                    </ClientSettings>              
                    
                    <MasterTableView DataKeyNames="Period" 
                                     EditMode="InPlace" CommandItemDisplay="Top"
                                     GroupLoadMode="Client"  GroupsDefaultExpanded="False"  
                                     AutoGenerateColumns="False">  

    Please help

    Thank you

  2. Eyup
    Admin
    Eyup avatar
    3867 posts

    Posted 24 Jul Link to this post

    Hi David,

    RadGrid provides drag-n-drop functionality for its rows, but not for cells:
    https://demos.telerik.com/aspnet-ajax/grid/examples/columns-rows/rows/drag-and-drop/defaultcs.aspx

    I can see that you have the AllowRowsDragDrop property disabled, which should mean that the item dragging is disabled. You can also check your Columns definition for GridRowIndicatorColumn.

    I've created a sample RadGrid web site using your exact grid definition code snippet. Could you run the attached application and modify it to demonstrate the mentioned dragging? Or you can send us sample screenshots or video. This will enable us to replicate the described behavior locally and provide more precise and accurate suggestions.

    You can run the Web site by following these steps:
    1. Open Visual Studio
    2. File menu
    3. Open option
    4. Select Web site and target the web site folder.
    5. Include a Bin folder with the Telerik dll assemblies.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  3. David
    David avatar
    278 posts
    Member since:
    Mar 2014

    Posted 26 Jul Link to this post

    Hi Eyup,

      Please add:

      protected void Page_PreRender(object sender, EventArgs e)

        {
            int totalCount = grdResourceGrid.MasterTableView.Items.Count - 2;

            int currentCount = 0;

            foreach (GridItem item in grdResourceGrid.MasterTableView.Items)
            {

                if (currentCount < totalCount)
                {
                    if (item.GetType().ToString() == "Telerik.Web.UI.GridDataItem")
                    {
                        GridEditableItem editableItem = (GridDataItem)item;
                        editableItem.Edit = true;
                    }
                }

                currentCount = currentCount + 1;
            }

            grdResourceGrid.Rebind();
        }

     

    Thank you

  4. Eyup
    Admin
    Eyup avatar
    3867 posts

    Posted 31 Jul Link to this post

    Hello David,

    This is a rather general behavior and you can restrict it using the following approach:
    <body ondragstart="return false;" ondrop="return false;">

    Per this suggestions:
    https://stackoverflow.com/a/13745199/6509119

    That should do the trick.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  5. David
    David avatar
    278 posts
    Member since:
    Mar 2014

    Posted 31 Jul in reply to Eyup Link to this post

    And it did!

    Thank you

Back to Top