Ticket T374602
Visible to All Users

GridControl - Tagging/Checkedit in Grid

created 9 years ago (modified 9 years ago)

Hi there,

Excuse me as this seems like it's been asked before but I can't seem to get it to work.

Essentially, I have a Grid that has a "Tag" column (a bool checkbox).
This could be pre-tagged from the database.

When a user tags a row, I want to ask the user a question "Are you sure?"
- If yes, I want to tag it and do something.
- If no, I want to cancel the whole thing - as if he did nothing.

My questions is/are:
When do you show the checkbox to cancel the editing if he says no? From other issues I've found, I'm to place it inside ShowingEditor - which does actually work, but if user chooses "Yes", I need the row to be tagged and commit the row - I don't want to stay in editing. How can I do this?
Reason for this, as if its in edit mode, the user can tag and untag it as much as he wants without ShowingEditor firing. I want it to fire every single time.

User flow:
Grid with taggable row : http://i.imgur.com/q453enz.png
User clicks the checkbox: http://i.imgur.com/AMgI49C.png
Presses Yes => Tag row and commit editing, but it says in edit form: http://i.imgur.com/IJbPE3E.png

My ShowingEditor method:

C#
private void gcLines_OnShowingEditor(object sender, ShowingEditorEventArgs e) { if (e.RowHandle != GridControl.AutoFilterRowHandle) { var viewModel = (LoadTrucksViewModel)this.DataContext; if ((bool)e.Value) { e.Cancel = !viewModel.AskToConfirmUnloadSelectedRoute(); if (!e.Cancel) { viewModel.LoadSelectedRoute(); } } else { e.Cancel = !viewModel.AskToConfirmLoadSelectedRoute(); if (!e.Cancel) { viewModel.LoadSelectedRoute(); } } } gcLines.View.PostEditor(); gcLines.View.CommitEditing(); e.Handled = true; }

I've tried adding those last 3 lines to no effect.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hi Christopher,
I suggest that you use the CellValueChanging event to catch the moment when a cell value is about to be changed and call the HideEditor method when it's necessary to preserve the current value. I have attached a sample project.

Thanks,
Alexander

    Show previous comments (1)
    Alexander Russkov (DevExpress) 9 years ago

      When DataControlDetailDescriptor is used, detail GridControls are copied from the grid specified in the DataControl property. As a result, the sender parameter in event handlers contains the GridControl (or TableView) defined in XAML and the real grid is stored in the Source property. So, the approach you are using is correct.

      Thanks,
      Alexander

      C C
      Christopher Calleja Urry 9 years ago

        Ok, thank you then!

        Alexander Russkov (DevExpress) 9 years ago

          You are welcome, Christopher!

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.