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

Disable Cell Drag and Drop

4 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Veteran
David asked on 19 Jul 2019, 02:43 PM

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

4 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Jul 2019, 11:26 AM
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.
0
David
Top achievements
Rank 1
Veteran
answered on 26 Jul 2019, 05:57 PM

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

0
Eyup
Telerik team
answered on 31 Jul 2019, 10:22 AM
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.
0
David
Top achievements
Rank 1
Veteran
answered on 31 Jul 2019, 12:30 PM

And it did!

Thank you

Tags
Grid
Asked by
David
Top achievements
Rank 1
Veteran
Answers by
Eyup
Telerik team
David
Top achievements
Rank 1
Veteran
Share this question
or