Ticket T305697
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

ASPxGridListEditor - Simplify the use of ImmediatePostData in editable List Views

Setting property values in inline edit mode

created 9 years ago

Hello

I have object A that contains a collection of object Bs in my application. In the detail view of object A I have a nasted list view of object Bs on a separate tab. B has two persistent string properties and a persistent boolean property that has ImmiediatePostData attribute. Now if the value of boolean prop changes to true, the string properties should be assigned a certain non-empty values. I do this in the OnChanged method of object B:

C#
if (propertyName == "FooBar") { if ((bool)newValue == true) { if (string.IsNullOrEmpty(Foo)) Foo= "text"; if (string.IsNullOrEmpty(Bar)) Bar= "text"; } }

It works well if I edit B in a popup window, but with inline editing the values are not being assigned, although the condition in OnChanged() methiod is being hit after I click the inner save button (so well they are actually being assigned, but after that the setter is accessed again with null value). I can't see any place in my code that could cause this. Any help would be appreciated.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello Matthews,

The issue occurs because of Web application specifics - when you click Save, a callback with the control's states is sent to the server. If a control's value has been changed, the application processes this and changes property values accordingly. If the value of the FooBar editor has been changed, your business logic is executed, and values of the Foo and Bar properties are updated. Then, values of the Foo and Bar editors are processed, and since values received from the client are different (empty), the server application considers that they have been changed and changes property values.
To solve the issue, you can enable the ImmediatePostData functionality for the FooBar property. See why it is disabled by default here: ASPxGridListEditor - Various side effects may occur when ImmediatePostData = True. Here is an example of how to enable it:

C#
using DevExpress.ExpressApp.Editors; using DevExpress.ExpressApp.Web.Editors; using DevExpress.ExpressApp.Web.Editors.ASPx; using DevExpress.ExpressApp.Web.SystemModule; public class ViewController1 : ObjectViewController<ListView, ObjectB> { protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); if (View.Editor is ASPxGridListEditor) { WebPropertyEditor booleanPropertyEditor = ((ASPxGridListEditor)View.Editor).FindPropertyEditor("FooBar", ViewEditMode.Edit); booleanPropertyEditor.ControlCreated += booleanPropertyEditor_ControlCreated; } } void booleanPropertyEditor_ControlCreated(object sender, EventArgs e) { ISupportImmediatePostData supportImmediatePostData = sender as ISupportImmediatePostData; supportImmediatePostData.SetImmediatePostDataCompanionScript(WebPropertyEditorImmediatePostDataController.ImmediatePostDataCompanionScript); supportImmediatePostData.SetImmediatePostDataScript(WebPropertyEditorImmediatePostDataController.GetImmediatePostDataScript()); } }

Please let me know if you need further assistance.

    Show previous comments (3)
    Anatol (DevExpress) 9 years ago

      Starting from version 15.2.9, you do not need to use this code to support the ImmediatePostData functionality in list views - see ASPxGridListEditor - Simplify the use of ImmediatePostData in editable List Views for details. If you need further assistance, let's continue this discussion in the Questions about ImmediatePostData in ASPxGridListEditor ticket.

        Hi,
        I've tried this solution. But, FindPropertyEditor() method returns null value for XAF/Web/ListView/Inline Edit/19.1.3.

        Other than this, if I set this parameters on Global.asax, the problem is resolving and FindPropertyEditor() method is returning the value.

        ASPxGridListEditor.UseASPxGridViewDataSpecificColumns = false;

        Unfortunately, Inline Edit mode, etc. features disappear, if I set.

        How can I do?

        Thanks ,
        Levent

        DevExpress Support Team 5 years ago

          Hello Levent,

          I've created a separate ticket on your behalf (T823845: The FindPropertyEditor method returns null value for ListView in the inline edit mode). It has been placed in our processing queue and will be answered shortly.

          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.