Beispiel #1
0
        protected void OnCancelCommand()
        {
            editState = DataGridEditState.None;

            if (EditMode == DataGridEditMode.Popup)
            {
                PopupVisible = false;
            }
        }
Beispiel #2
0
        protected async Task OnSaveCommand()
        {
            if (Data == null)
            {
                return;
            }

            // get the list of edited values
            var editedCellValues = EditableColumns
                                   .Select(c => new { c.Field, editItemCellValues[c.ElementId].CellValue }).ToDictionary(x => x.Field, x => x.CellValue);

            var rowSavingHandler = editState == DataGridEditState.New ? RowInserting : RowUpdating;

            if (await IsSafeToProceed(rowSavingHandler, editItem, editedCellValues))
            {
                if (UseInternalEditing && editState == DataGridEditState.New && CanInsertNewItem && Data is ICollection <TItem> data)
                {
                    data.Add(editItem);
                }

                if (UseInternalEditing || editState == DataGridEditState.New)
                {
                    // apply edited cell values to the item
                    // for new items it must be always be set, while for editing items it can be set only if it's enabled
                    foreach (var column in EditableColumns)
                    {
                        column.SetValue(editItem, editItemCellValues[column.ElementId].CellValue);
                    }
                }

                if (editState == DataGridEditState.New)
                {
                    await RowInserted.InvokeAsync(new SavedRowItem <TItem, Dictionary <string, object> >(editItem, editedCellValues));

                    dirtyFilter = dirtyView = true;

                    // If a new item is added, the data should be refreshed
                    // to account for paging, sorting, and filtering
                    if (ManualReadMode)
                    {
                        await HandleReadData();
                    }
                }
                else
                {
                    await RowUpdated.InvokeAsync(new SavedRowItem <TItem, Dictionary <string, object> >(editItem, editedCellValues));
                }

                editState = DataGridEditState.None;

                if (EditMode == DataGridEditMode.Popup)
                {
                    PopupVisible = false;
                }
            }
        }
Beispiel #3
0
        protected void OnEditCommand(TItem item)
        {
            InitEditItem(item);

            editState = DataGridEditState.Edit;

            if (EditMode == DataGridEditMode.Popup)
            {
                PopupVisible = true;
            }
        }
Beispiel #4
0
        protected void OnNewCommand()
        {
            InitEditItem(CreateNewItem());

            editState = DataGridEditState.New;

            if (EditMode == DataGridEditMode.Popup)
            {
                PopupVisible = true;
            }
        }
Beispiel #5
0
        protected void OnNewCommand()
        {
            var newItem = CreateNewItem();

            NewItemDefaultSetter?.Invoke(newItem);

            InitEditItem(newItem);

            editState = DataGridEditState.New;

            if (EditMode == DataGridEditMode.Popup)
            {
                PopupVisible = true;
            }
        }
Beispiel #6
0
        protected async Task OnSaveCommand()
        {
            if (Data is ICollection <TItem> data)
            {
                // get the list of edited values
                var editedCellValues = EditableColumns
                                       .Select(c => new { c.Field, editItemCellValues[c.ElementId].CellValue }).ToDictionary(x => x.Field, x => x.CellValue);

                if (IsSafeToProceed(RowSaving, editItem, editedCellValues))
                {
                    if (UseInternalEditing && editState == DataGridEditState.New && CanInsertNewItem)
                    {
                        data.Add(editItem);
                    }

                    if (UseInternalEditing || editState == DataGridEditState.New)
                    {
                        // apply edited cell values to the item
                        // for new items it must be always be set, while for editing items it can be set only if it's enabled
                        foreach (var column in EditableColumns)
                        {
                            column.SetValue(editItem, editItemCellValues[column.ElementId].CellValue);
                        }
                    }

                    if (editState == DataGridEditState.New)
                    {
                        await RowInserted.InvokeAsync(new SavedRowItem <TItem, Dictionary <string, object> >(editItem, editedCellValues));

                        dirtyFilter = dirtyView = true;
                    }
                    else
                    {
                        await RowUpdated.InvokeAsync(new SavedRowItem <TItem, Dictionary <string, object> >(editItem, editedCellValues));
                    }

                    editState = DataGridEditState.None;

                    if (EditMode == DataGridEditMode.Popup)
                    {
                        PopupVisible = false;
                    }
                }
            }
        }
 public PopupTitleContext(TItem item, DataGridEditState editState)
 {
     Item      = item;
     EditState = editState;
 }
 protected void OnCancelCommand()
 {
     editState = DataGridEditState.None;
 }
        protected void OnEditCommand(TItem item)
        {
            InitEditItem(item);

            editState = DataGridEditState.Edit;
        }
        protected void OnNewCommand()
        {
            InitEditItem(CreateNewItem());

            editState = DataGridEditState.New;
        }
Beispiel #11
0
 public PopupTitleContext(TItem item, DataGridEditState editState, string localizationString)
 {
     Item               = item;
     EditState          = editState;
     LocalizationString = localizationString;
 }