logoEnterprise-level component library based on Bootstrap and Blazor
gitee
version
license
download
repo
commit
build
coverage

DragDrop

For drag and drop

simple drag and drop

Demo
1
2
3
4
5
6
7
8
9
10

Use CopyItem to copy a new copy to a new location

Demo
1
2
3
4
5
6
7
8
9
10

Use Accepts to only allow 10 drags on the left and use AllowsDrag to limit 2 to not be dragged, use MaxItems to limit the right to have a maximum of 6 nodes

Demo
1
2
3
4
5
6
7
8
9
10

When the dragging quantity exceeds the limit OnItemDropRejectedByMaxItemLimit, when dragging is prohibited OnItemDropRejected, return to the bottom ItemOnReplacedItemDrop, return the dropped Item OnItemDrop

Demo
1
2
3
4
5
6
7
8
9
10

Attributes

Loading...

Methods

Loading...
@page "/dragdrops"
@inject IStringLocalizer<DragDrops> Localizer

<h3>DragDrop</h3>

<h4>For drag and drop</h4>

<DemoBlock Title="Basic usage" Introduction="simple drag and drop" Name="Normal">
    <Row ItemsPerRow="ItemsPerRow.Two">
        <Dropzone TItem="string" Items="@StrList1">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
        <Dropzone TItem="string" Items="@StrList2">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
    </Row>
</DemoBlock>

<DemoBlock Title="Copy to new container" Introduction="Use <code>CopyItem</code> to copy a new copy to a new location" Name="Normal">
    <Row ItemsPerRow="ItemsPerRow.Two">
        <Dropzone TItem="string" Items="@StrList1">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
        <Dropzone TItem="string" Items="@StrList2" CopyItem="s => new string(s)">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
    </Row>
</DemoBlock>

<DemoBlock Title="Limit what can be dragged in" Introduction="Use <code>Accepts</code> to only allow 10 drags on the left and use <code>AllowsDrag</code> to limit 2 to not be dragged, use <code>MaxItems</code> to limit the right to have a maximum of 6 nodes" Name="Normal">
    <Row ItemsPerRow="ItemsPerRow.Two">
        <Dropzone TItem="string" Items="@StrList1" Accepts="@((s, s1) => s == "10")" AllowsDrag="@(s => s != "2")">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
        <Dropzone TItem="string" Items="@StrList2" MaxItems="6">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
    </Row>
</DemoBlock>

<DemoBlock Title="Various events" Introduction="When the dragging quantity exceeds the limit <code>OnItemDropRejectedByMaxItemLimit</code>, when dragging is prohibited <code>OnItemDropRejected</code>, return to the bottom Item<code>OnReplacedItemDrop</code>, return the dropped Item<code> OnItemDrop</code>" Name="Normal">
    <Row ItemsPerRow="ItemsPerRow.Two">
        <Dropzone TItem="string" Items="@StrList1" Accepts="@((s, s1) => s == "10")" OnItemDropRejected="@OnItemDropRejected" OnItemDrop="@OnItemDrop" OnReplacedItemDrop="@OnReplacedItemDrop">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
        <Dropzone TItem="string" Items="@StrList2" MaxItems="6" OnItemDropRejectedByMaxItemLimit="@OnItemDropRejectedByMaxItemLimit" OnItemDrop="@OnItemDrop" OnReplacedItemDrop="@OnReplacedItemDrop">
            <Card IsShadow="true">
                <BodyTemplate>
                    @context
                </BodyTemplate>
            </Card>
        </Dropzone>
    </Row>
    <BlockLogger @ref="Trace" class="mt-3" />
</DemoBlock>

<AttributeTable Items="@GetAttributes()" />

<MethodTable Items="GetMethods()"></MethodTable>
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/

namespace BootstrapBlazor.Shared.Samples;

/// <summary>
///
/// </summary>
public partial class DragDrops
{
    [NotNull]
    private List<string>? StrList1 { get; set; }

    [NotNull]
    private List<string>? StrList2 { get; set; }

    [NotNull]
    private BlockLogger? Trace { get; set; }

    /// <summary>
    ///
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();
        StrList1 = new List<string>()
        {
            "1",
            "2",
            "3",
            "4",
            "5"
        };
        StrList2 = new List<string>()
        {
            "6",
            "7",
            "8",
            "9",
            "10"
        };
    }

    private void OnReplacedItemDrop(string item)
    {
        Trace?.Log($"新元素放在{item}下");
    }

    private void OnItemDrop(string item)
    {
        Trace?.Log($"{item}被放下");
    }

    private void OnItemDropRejected(string item)
    {
        Trace?.Log($"{item}被拒绝");
    }

    private void OnItemDropRejectedByMaxItemLimit(string item)
    {
        Trace?.Log($"{item}由于超过最大数量限制被禁止");
    }

    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
    {
        new()
        {
            Name = "MaxItems",
            Description = Localizer["A1"],
            Type = "int?",
            ValueList = " — ",
            DefaultValue = "null"
        },
        new()
        {
            Name = "ChildContent",
            Description = Localizer["A1"],
            Type = "RenderFragment<TItem>?",
            ValueList = " — ",
            DefaultValue = " — "
        },
    };

    private IEnumerable<MethodItem> GetMethods() => new MethodItem[]
    {
        new()
        {
            Name = nameof(Dropzone<MethodItem>.Accepts),
            Description = Localizer["M1"],
            Parameters = "Func<TItem?, TItem?, bool>",
            ReturnValue = "bool "
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.AllowsDrag),
            Description = Localizer["M2"],
            Parameters = "TItem",
            ReturnValue = "bool"
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.CopyItem),
            Description = Localizer["M3"],
            Parameters = "TItem, TItem",
            ReturnValue = "TItem"
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.ItemWrapperClass),
            Description = Localizer["M4"],
            Parameters = "TItem",
            ReturnValue = "string"
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.OnItemDrop),
            Description = Localizer["M5"],
            Parameters = " — ",
            ReturnValue = " — "
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.OnItemDropRejected),
            Description = Localizer["M6"],
            Parameters = " — ",
            ReturnValue = " — "
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.OnReplacedItemDrop),
            Description = Localizer["M7"],
            Parameters = " — ",
            ReturnValue = " — "
        },
        new()
        {
            Name = nameof(Dropzone<MethodItem>.OnItemDropRejectedByMaxItemLimit),
            Description = Localizer["M8"],
            Parameters = " — ",
            ReturnValue = " — "
        }
    };
}

B station related video link

No

交流群

QQ Group:BootstrapAdmin & Blazor 795206915 675147445 Welcome to join the group discussion
img
Themes
Bootstrap
Motronic
Ant Design (完善中)
DevUI (制作中)
LayUI (完善中)
An error has occurred. This application may no longer respond until reloaded. Reload
Seems like the connection with the server has been lost. It can be due to poor or broken network. Please hang on while we're trying to reconnect...
Oh snap! Failed to reconnect with the server. This is typically caused by a longer network outage, or if the server has been taken down. You can try to reconnect, but if that does not work, you need to reload the page.
Oh man! The server rejected the attempt to reconnect. The only option now is to reload the page, but be prepared that it won't work, since this is typically caused by a failure on the server.
Bootstrap Blazor Component library updated to 7.0.8-beta05

Bootstrap Blazor at present has more than 120 components. This component is based on Bootstrap Blazor An enterprise-level component library that provides several types of common components such as layout, navigation, form, data, notification, icon, voice, etc. Each component has been carefully designed with modularity, responsiveness and excellent performance. Starting from more practical scenarios, meeting the needs of various scenarios, greatly reducing the time cost of developers, greatly shortening the development cycle, greatly improving development efficiency, and providing a set of General Rights Management System Example project。Bootstrap Blazor Products are maintained by a professional full-time technical team, with efficient response speed, diversified solutions, long-term support, and enterprise-level support. At present, it has been used in many well-known state-owned enterprises, and the project is running stably with a maximum of 1200 people online. On the right is the QR code of the Chinese Blazor QQ community with the largest number of people in China, welcome to scan and join the group.

component updated to 6.6.0 Change log [portal] If the component brings you convenience, please help to light up the project Star github gitee

QQGroup
QQ 795206915