Completed
Last Updated: 27 Apr 2022 13:04 by ADMIN
Release 3.3.0
Gabriele
Created on: 21 May 2021 09:37
Category: Grid
Type: Bug Report
8
The Drag and Drop functionality does not enable properly when the RowDraggable parameter is bound to a bool parameter
I am using a bool property to control whether the rows of the Grid would be draggable. When I try to toggle the value of this property the feature is not enabled or disabled accordingly. 
2 comments
ADMIN
Dimo
Posted on: 17 Feb 2022 08:47

Hi all,

This issue should be fixed in a few weeks. In the meantime, you can use the following workaround:

  • Enable dragging initially, but hide the drag column with CSS
  • Disable dragging in OnAfterRenderAsync and remove the CSS styles, which hide the drag column
<TelerikGrid Data="@GridData" RowDraggable="@CanDrag" Class="@DragClass">
    <GridToolBar>
        <GridCommandButton OnClick="@ToggleDrag">Toggle Drag</GridCommandButton>
    </GridToolBar>
    <GridColumns>
        <GridColumn Field="@(nameof(TestModel.Name))" />
    </GridColumns>
</TelerikGrid>

<style>
    .k-grid.hide-drag-column .k-drag-col {
        width: 0;
    }
    .k-grid.hide-drag-column .k-drag-cell {
        visibility: hidden;
    }
</style>

@code {
    bool CanDrag { get; set; } = true;
    string DragClass { get; set; } = "hide-drag-column";

    void ToggleDrag(GridCommandEventArgs args)
    {
        CanDrag = !CanDrag;
    }

    protected override Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            CanDrag = false;
            DragClass = "";
        }

        return base.OnAfterRenderAsync(firstRender);
    }

    IEnumerable<TestModel> GridData { get; set; } = Enumerable.Range(1, 5)
        .Select(x => new TestModel {
            ID = x, Name = $"Name {x}"
    });

    public class TestModel
    {
        public string Name { get; set; }
        public int ID { get; set; }
    }
}

 

Regards,
Dimo
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Steve
Posted on: 25 Jun 2021 15:39
I have the same problem.  When ReorderMode is set to true, the grid "looks" like it will allow reorder but dragging has no effect.