Refreshing a grid when contents are changed in a different window

Refreshing a grid when contents are changed in a different window

Old forum URL: forums.lhotka.net/forums/t/3628.aspx


lektira posted on Monday, October 01, 2007

Hello,

I am quite new to CSLA, and I might be stuck with a basic question.

Namely, I have a grid containing a number of objects created from a class called ProductsInfo, which is a readonlylistbase. They contain only four fields that are displayed in the grid.
When any of the items is double clicked, a full Product object(businessbase) is created where users can modify the object itself in a new window. At the same time, the grid stays in the background. When fields are modified in the new window, I need to make sure that the fields in the grid are automatically refreshed/refetched accordingly when the Product object is saved. They are both different types of objects but deal with the same fields of the same database tables.

Is this possible, and if it is, how can it be achieved?

Thank you in  advance,
lektira

KKoteles replied on Monday, October 01, 2007

lektira,

Assuming you are following Rocky's examples, your Product object should call the ProductList (which should be the ReadOnlyListBase object containing the collection of ProductInfo objects) object's InvalidateCache() method in both the object's Save() and DataPortal_OnDataPortalInvokeComplete() methods.  This would ensure the caching of the ProductList gets invalidated; however, it does nothing to "signal" to your background grid form that it needs to refresh itself.  You would need to add an event from your Product object related form back to your ProductList related form - such that when it was fired the ProductList related form would know to "refresh" itself by calling the Get() method of the ProductList once again to get the latest information.  You might need to save the ID value of the object selected in the grid in order to reposition back to it when the grid is re-bound / refreshed.

All your object's are working just fine, but you need to work on your UI a little more.

Cheers,

Ken

JoeFallon1 replied on Monday, October 01, 2007

I believe many people use the Observer pattern for this.

Active Objects uses it extensively. Many devs use it.

Search the forum for more info on Active Objects.

Joe

 

KKoteles replied on Tuesday, October 02, 2007

lektira,

OK, I found this on Rocky's site and it may be just what you are looking for:

http://www.lhotka.net/weblog/IAmWorkingOnMyUsingCSLANET30EbookAndWroteSomeContentThatIDontThinkImGoingToUseInTheBook.aspx

Ken

lektira replied on Wednesday, October 03, 2007

Hi,

I'm sorry I haven't replied for couple of days. In any case, thanks to both of you for being a great help. I could use both of the suggestions you made, but with the deadline approaching, Rocky's solution seemed the quickest. I wonder why he doesn't put it in the book.

Thanks again!

Cheers,
lektira

 

lektira replied on Wednesday, October 03, 2007

Hi,

I'm sorry I haven't replied for couple of days. In any case, thanks to both of you for being a great help. I could use both of the suggestions you made, but with the deadline approaching, Rocky's solution seemed the quickest. I wonder why he doesn't put it in the book.

Thanks again!

Cheers,
lektira

dmccrory replied on Thursday, October 04, 2007

I am having 2 issues when implementing the code that is listed in the link.

  1. When the code below is called, this.IsNew property is false so the if(old.IsNew) statement in the Customer_Saved method always fails. Did I miss something?

               protected override Customer Save()

    {

      Customer result = base.Save();

      OnCustomerSaved(this, new Csla.Core.SavedEventArgs(result));

      return result;

    }

  }

Deleting an object. Should I include a Remove() function in the CustomerList object that deletes the current object and removes it from the list? Or is there a better way to do this?

Copyright (c) Marimer LLC