Giter VIP home page Giter VIP logo

Comments (7)

Postlagerkarte avatar Postlagerkarte commented on July 27, 2024

Hi @bancroftway ,

have you cleared he Dropzone before assigning the new items? Check #23

from blazor-dragdrop.

bancroftway avatar bancroftway commented on July 27, 2024

In the example I cited above, where would I write the code for clearing the dropzone? I tried OnParameterSetAsync, but got this error:

Just to be clear, the component's Items property is not being "set", but is "bound" to a Linq expression.

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Sequence contains no matching element System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.Single[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func2[T,TResult] predicate) <0x321ea60 + 0x0011a> in <filename unknown>:0 at Blazor.DragDrop.Core.DragDropService.ClearDropzone (System.String dropzoneName) <0x3217a68 + 0x00030> in <filename unknown>:0 at DPlan.Client.UIComponents.SkidPatternCmp.OnParametersSetAsync () [0x00001] in C:\Projects\UIComponents\SkCmp.razor:64 at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync () <0x2d26980 + 0x00014> in <filename unknown>:0 at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync () <0x2d26380 + 0x00146> in <filename unknown>:0

from blazor-dragdrop.

Postlagerkarte avatar Postlagerkarte commented on July 27, 2024

Did you pass the correct Dropzone Name?

Nevertheless, If you can provide a small example project I can take a further look at the issue.

from blazor-dragdrop.

bancroftway avatar bancroftway commented on July 27, 2024

I have a reproduction here.

In this project, from the Customers dropdown, first select Customer1, and then Customer2. The Customer2's orders get appended to DropZone as shown in screenshot. I am wondering, where exactly would I code the Dropzone.Clear in this case.

image

from blazor-dragdrop.

Postlagerkarte avatar Postlagerkarte commented on July 27, 2024

Try

private async Task HandleCustomerSelection(ChangeEventArgs e)
    {
        if (e.Value != null && !string.IsNullOrEmpty(e.Value.ToString()))
        {
            DragDropService.ClearDropzone("dZone");
            SelectedCustomerId = new Guid(e.Value.ToString());
            StateHasChanged();
        }
    }

from blazor-dragdrop.

bancroftway avatar bancroftway commented on July 27, 2024

@Postlagerkarte while the provided solution works, it is a bit unclean, in that the parent component is intimately aware of the child component's inner workings, breaking encapsulation.

Secondly, if the Order has a property IsDeleted to soft-delete an order, and the requirement is that when user presses 'Delete' button on an order, the order should be removed from the list, in such a case, how would we handle clearing and re-binding the dropzone, from within the component?

from blazor-dragdrop.

Postlagerkarte avatar Postlagerkarte commented on July 27, 2024

Hi @bancroftway , I agree with you but I am not planning to do any major work on the library except bugfixes until the Blazor Team has finalized how DragDrop looks like in .NET 5 Blazor.

For the second point - did you check #6 ? It shows how to remove an item when a users presses delete.

from blazor-dragdrop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.