Ticket Q529421
Visible to All Users

How to refresh nested ListView after adding record by PopupWindowShowAction?

created 12 years ago

How to refresh nested ListView after adding record by PopupWindowShowAction?

C#
public partial class ActivityItemViewController : ViewController { public ActivityItemViewController() { InitializeComponent(); RegisterActions(components); TargetObjectType = typeof(ActivityItem); TargetViewType = ViewType.ListView; } private ActivityItem _activityItem; private void addActivityItemAction_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { IObjectSpace objectSpace = Application.CreateObjectSpace(); _activityItem = objectSpace.CreateObject<ActivityItem>(); var detView = Application.CreateDetailView(objectSpace, "ActivityItem_DetailView", true, _activityItem); e.View = detView; } private void addActivityItemAction_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { //!!! NOT REFRESHED View.ObjectSpace.Refresh(); View.Refresh(); } }
Comments (1)
SP SP
Sergey Polischuk 12 years ago

    Solved the problem:
    ((ListView)View).CollectionSource.Add(_activityItem);
    Thanks!

    Answers approved by DevExpress Support

    created 12 years ago (modified 12 years ago)

    Hello Sergey,
    Normally, the View.ObjectSpace.Refresh is a good and reliable means to refresh data in a View. If this does not work in your case, then most likely you are trying to refresh a different View. So, I suggest you set a breakpoint at this line and verify in the debugger that the View is actually the View you want to be refreshed.
    Take special note that your data should be physically committed to the database at this moment. If this is not the case, you can call the IObjectSpace.CommitChanges method at the end of the routine where you added new records.
    If committing is not supposed to be done according to your business logic, you can consider adding records directly into the ListView.CollectionSource of a required screen.

      Comments (2)
      SP SP
      Sergey Polischuk 12 years ago

        Thanks, Dennis!
        Indeed, it was necessary to first save and then refreshed.

        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.