Ticket S30324
Visible to All Users

GridListEditor - Updating values of dependent columns immediately after changing data in columns whose ImmediatePostData attribute is set to True in an editable ListView

created 17 years ago (modified 9 years ago)

Scenario
Suppose we have implemented calculated properties as described in the Make a Property Calculable  article and want to achieve the effect shown in the attached video (ExpectedResults.swf).

Problem description
Currently, if we even mark this property with the ImmediatePostDataAttribute, the changes will be immediately reflected only in detail view, but not in the edited list view. This behavior is caused by WinForms XtraGrid specifics - it does not post the editor's value to the datasource until the cell's editor is closed or loses focus. To support this, we need to write a VewController that will handle the changes of each cell in the row those column property is marked with the ImmediatePostDataAttribute.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

We have implemented the functionality described in this ticket. It will be included in our next update(s).

Please check back and leave a comment to this response to let us know whether or not this solution addresses your concerns.

Additional information:

Starting with version 15.2.10, the previous custom-tailored solution is no longer required, as this code has been moved to the standard delivery.
Not to cause breaking changes a minor 15.2 version, you can activate this behavior in an editable GridListEditor via the static ImmediatePostDataSupportEnabled option:

C#
... namespace MainDemo.Win { public class Program { [STAThread] public static void Main(string[] arguments) { DevExpress.ExpressApp.Win.Editors.GridListEditor.ImmediatePostDataSupportEnabled = true; ...

The ImmediatePostDataSupportEnabled option has its default value set to True by default in v16.1.

You can test this improvement right away after installing the following hot fix build: http://downloads.devexpress.com/Share/DXP/S30324/DevExpressComponents-15.2.9.16105.exe
I am looking forward to hearing from you once you have had an opportunity to test the latest build with your real WinForms projects.

    created 17 years ago (modified 9 years ago)

    Current solution
    To post the value immediately, access the underlying data bound control as per the Access Grid Control Properties  article and subscribe to the editor's  RepositoryItem.EditValueChanged event to call the ColumnView.PostEditormethod. Refer to the related WinForms documentation articles for more details:
        How to save the value of an in-place check box as soon as it is changed
        How to immediately update GridView states after a cell value is changed
    Here is also a working example for the GridListEditor class (v15.2.9):

    C#
    using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Win.Editors; namespace MainDemo.Module.Win.Controllers { public class ImmediatePostDataListViewController : ViewController<ListView> {   GridListEditor gridListEditor = null;   protected override void OnViewControlsCreated() {    base.OnViewControlsCreated();    if(View.AllowEdit) {     gridListEditor = View.Editor as GridListEditor;     if(gridListEditor != null) {      foreach(XafGridColumnWrapper cw in gridListEditor.Columns) {       if((cw.GridColumnInfo != null) && (cw.GridColumnInfo.Model != null) && cw.GridColumnInfo.Model.ImmediatePostData) {        cw.Column.ColumnEdit.EditValueChanged += ColumnEdit_EditValueChanged;       }      }     }    }   }   private void ColumnEdit_EditValueChanged(object sender, EventArgs e) {    gridListEditor.ColumnView.PostEditor();   }   protected override void OnDeactivated() {    base.OnDeactivated();    if(gridListEditor != null) {     foreach(XafGridColumnWrapper cw in gridListEditor.Columns) {      if((cw.GridColumnInfo != null) && (cw.GridColumnInfo.Model != null) && cw.GridColumnInfo.Model.ImmediatePostData) {       cw.Column.ColumnEdit.EditValueChanged -= ColumnEdit_EditValueChanged;      }     }    }   } } }
    Visual Basic
    Imports System Imports DevExpress.ExpressApp Imports DevExpress.ExpressApp.Win.Editors Namespace MainDemo.Module.Win.Controllers Public Class ImmediatePostDataListViewController   Inherits ViewController(Of ListView)   Private gridListEditor As GridListEditor = Nothing   Protected Overrides Sub OnViewControlsCreated()    MyBase.OnViewControlsCreated()    If View.AllowEdit Then     gridListEditor = TryCast(View.Editor, GridListEditor)     If gridListEditor IsNot Nothing Then      For Each cw As XafGridColumnWrapper In gridListEditor.Columns       If (cw.GridColumnInfo IsNot Nothing) AndAlso (cw.GridColumnInfo.Model IsNot Nothing) AndAlso cw.GridColumnInfo.Model.ImmediatePostData Then        AddHandler cw.Column.ColumnEdit.EditValueChanged, AddressOf ColumnEdit_EditValueChanged       End If      Next cw     End If    End If   End Sub   Private Sub ColumnEdit_EditValueChanged(ByVal sender As Object, ByVal e As EventArgs)    gridListEditor.ColumnView.PostEditor()   End Sub   Protected Overrides Sub OnDeactivated()    MyBase.OnDeactivated()    If gridListEditor IsNot Nothing Then     For Each cw As XafGridColumnWrapper In gridListEditor.Columns      If (cw.GridColumnInfo IsNot Nothing) AndAlso (cw.GridColumnInfo.Model IsNot Nothing) AndAlso cw.GridColumnInfo.Model.ImmediatePostData Then       RemoveHandler cw.Column.ColumnEdit.EditValueChanged, AddressOf ColumnEdit_EditValueChanged      End If     Next cw    End If   End Sub End Class End Namespace

    Note: This code is supposed to perform dependent columns within the focused row only. If your cell editor changes affect other rows, use the solution from the ImmediatePostData - Immediate refresh of other row thread.

      Show previous comments (3)
      Dennis Garavsky (DevExpress) 11 years ago

        @Nick: Am I correct that you are having problems with handling events for check box columns with the TreeListEditor?
        I am asking because inplace editing is not currently supported (ListEditors.TreeList - Make it possible to edit data directly in the tree list (inplace/inline edit)). I am afraid we do not have ready temporary solutions for this and we have not yet researched best ways to implement this task either, so we cannot advise on how to modify your current XAF code to force it to work as expected. We hope to allocate time and resources for this task when this feature is scheduled for a certain release. In the meantime, I can only recommend you implement this task without XAF using a pure TreeList control wrapped into a custom List Editor for its use in XAF ListView. Please refer to the XtraTreeList documentation or contact our WinForms team if you require assistance on how to properly use the control in this scenario to get checkboxes working as you want. Our support team will be glad to assist you further.

          Hi Dennis, indeed the problem I came across is to do with checkbox columns in TreeListEditor. However, the only thing that doesn't work is the immediate post changes, it works just fine otherwise, so if the field looses focus the update happens just fine (I'm using Expand Framework XpandTreeListEditor). So in-place editing work just fine and it seems the issue is more to do with CheckEdit rather than with anything else.

          Dennis Garavsky (DevExpress) 11 years ago

            Thanks for your update, Nick. Then, I suggest you replicate the same issue within a non-XAF form with a tree list control using check boxes for its columns and report this sample to our XtraTreeList team. As I mentioned above, we will be glad to assist you in solving this problem.

            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.