private void OnDragStart(DragEventArgs _) { _dragging = true; // need to set the data being dragged if (DragContext != null && KeyField != null) { // get all selected items var items = new List <TItem>(); foreach (var key in Selection) { var item = ItemsToDisplay.Find(x => KeyField(x).ToString() == key); if (item != null) { items.Add(item); } } DragContext.Payload = items; } }
/// <summary> /// Begins editing of the given item. /// </summary> public async Task BeginEditAsync() { if (AllowEdit && !IsEditing && SelectionMode != TableSelectionMode.None && Selection.Count == 1 && KeyField != null) { // find item to edit var item = ItemsToDisplay.Find(x => KeyField(x).ToString() == Selection[0]); if (item != null) { // notify and allow for cancel EditItem = item; _tableBeforeEditArgs = new TableBeforeEditEventArgs <TItem>(EditItem); await InvokeAsync(async() => await BeforeEdit.InvokeAsync(_tableBeforeEditArgs).ConfigureAwait(true)).ConfigureAwait(true); if (!_tableBeforeEditArgs.Cancel) { _editValues.Clear(); IsEditing = true; BeginEditEvent.Set(); await InvokeAsync(StateHasChanged).ConfigureAwait(true); } } } }