ZeroCodeException
ZeroCodeException

Reputation: 123

MudBlazor DropZone "onChange" event

I need to save the log of the movements between Dropzones in a database.

I have the connection made with swagger so i only need to call a function that write the change (for example, i move 'Francisco' item to 'Super ocupados' drop zone):

enter image description here

And in that change i want to call this async method (Imagine that it writes the change in the bd):

enter image description here

There is some way to detect this change and call a function, something like an 'OnDroppedItem' or an 'OnChange'?

I think that there isn't an easy way to do this so... how i made this log?

Upvotes: 1

Views: 1244

Answers (2)

Dominik
Dominik

Reputation: 299

I think what you are looking for is the EventCallback ItemDropped. You can information with example code here.

The code you are looking for from the documentation:


<MudDropContainer T="DropItem" Items="_items" ItemsSelector="@((item,dropzone) => item.Identifier == dropzone)" ItemDropped="ItemUpdated" Class="d-flex flex-wrap flex-grow-1">
....
</MudDropContainer>

@code
{
    private void ItemUpdated(MudItemDropInfo<DropItem> dropItem)
    {
        dropItem.Item.Identifier = dropItem.DropzoneIdentifier;
    }
}

Upvotes: 1

ZeroCodeException
ZeroCodeException

Reputation: 123

Oh my god, i am so dumb that i havent realized that in the first example code of mudblazor page (code that i literally copy and paste) there was a function that make this:

enter image description here

Sorry for this, i think that im not going to delete the question because maybe this help someone whit the same problem in the future :/

Upvotes: 0

Related Questions