New Posts New Posts RSS Feed: Current cell in grid... stale data
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Current cell in grid... stale data

 Post Reply Post Reply
Author
MichaelNiemann View Drop Down
Newbie
Newbie


Joined: 12-Jul-2007
Posts: 10
Post Options Post Options   Quote MichaelNiemann Quote  Post ReplyReply Direct Link To This Post Topic: Current cell in grid... stale data
    Posted: 12-Jul-2007 at 8:41am
Hello, I'm a DevForce newbie... so be gentle.
 
I was working through the tutuorial (I appreciate the compile errors intended to keep me focused on the code details <g>)...
 
If I change a cell in a grid, and then DiscardChanges... the changed value remains displayed in the cell, until you change focus to another cell in that grid. Is this the intended behavior of DevForce, or am I expecting way too much at this level of the tutorial?
 
BTW, if you try to SaveChanges after the DiscardChanges... then the value in the grid _is_ updated to the current value (after the "No data to save" message, and without touching the grid). Of course, this is probably because the aborted Save continues to refresh the entire UI.
 
Anyway, just a newbie post from someone looking at the FrameWork.
 
Regards, Mike
Back to Top
MichaelNiemann View Drop Down
Newbie
Newbie


Joined: 12-Jul-2007
Posts: 10
Post Options Post Options   Quote MichaelNiemann Quote  Post ReplyReply Direct Link To This Post Posted: 13-Jul-2007 at 9:32am
Me again.

When I mentioned that "the grid is updated to the current value" in the BTW comment, I probably should have said "the grid is updated to the original value".

And now along the same lines only worse... I was executing the "Security_Role-Based Authorization" example, and the problem there is even worse. I logged on as "nancyd", and after changing the "order date" for one of the orders (and tabbing to the next cell), I "Discard all changes".

However, the data is permanently saved rather than discarded!


Edited by MichaelNiemann - 13-Jul-2007 at 9:33am
Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 13-Jul-2007 at 2:41pm
Michael,
 
Yes.  The fact that the change doesn't show up immediately is a known behavior of binding.  Fortunately, there is a way to fix this behavior.  Please read and study the advanced tutorial on "Refreshing Dependent Parents".
 
I couldn't reproduce your save problem.  When I clicked on "Save All Changes".  I got the message, "There are no changes to save".
 
If you want to get my completed solution, send me an email at davidk@ideablade.com
 
 


Edited by IdeaBlade - 13-Jul-2007 at 2:52pm
Back to Top
MichaelNiemann View Drop Down
Newbie
Newbie


Joined: 12-Jul-2007
Posts: 10
Post Options Post Options   Quote MichaelNiemann Quote  Post ReplyReply Direct Link To This Post Posted: 16-Jul-2007 at 6:38am
DavidK,
 
You must leave the cell (tab out) before saving to see the problem.
 
It is another manifestation of the "display doesn't show up immediately". I will check out "Refreshing Dependent Parents".
 
Thank you.
Back to Top
MichaelNiemann View Drop Down
Newbie
Newbie


Joined: 12-Jul-2007
Posts: 10
Post Options Post Options   Quote MichaelNiemann Quote  Post ReplyReply Direct Link To This Post Posted: 16-Jul-2007 at 11:48am
DavidK,

OK, so the problem is not the framework, but a repaint bug in DataGridView. that is good. BTW, I fixed the problem with:

    private void RejectAllChanges() {
      if (mPersMgr.HasChanges()) {
        mPersMgr.RejectChanges();
        mMainTabControl.Refresh();  //added to fix DataGridView repaint bug
        MessageBox.Show("All pending changes undone.");
      } else {
        MessageBox.Show("No changes to undo.");
      }
    }


However, one answer leads to more questions...
As the "TechTip_Refreshing Dependent Parents.doc" points out, figuring out which nested component to signal from which event can be difficult (which is why I went for the "repaint everything in the container" approach).

But wouldn't a well engineered "workaround" for the DGV bug be along the lines... for the BO that I just RejectedChanges on, repaint all DGV's that are bound to the my properties (persistent and non-persistent)??

I would hope the "subscribers / bound controls" of the UI can be determined by the BO's.

Mike


Edited by MichaelNiemann - 24-Jul-2007 at 9:25am
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 24-Jul-2007 at 3:27pm
>>
As the "TechTip_Refreshing Dependent Parents.doc" points out, figuring out which nested component to signal from which event can be difficult (which is why I went for the "repaint everything in the container" approach).

But wouldn't a well engineered "workaround" for the DGV bug be along the lines... for the BO that I just RejectedChanges on, repaint all DGV's that are bound to the my properties (persistent and non-persistent)??
<<
 
Probably much more often than not, you'll be rejecting changes not on a single BO, but a whole slew of them, often including different types (Employees, Order, OrderDetails, etc.)

>>
I would hope the "subscribers / bound controls" of the UI can be determined by the BO's.
<<
 
With DevForce databinding, all the bindings to a type (e.g., Employee) are collected in the Descriptors (BindingDescriptors) collection of a BindingManager. So you could tell from that which UI controls are bound to the Employee you just undid (if that's all you undid).
 
I suppose you could write a method that iterates through all of the BindingManagers in a particular context (e.g., on a particular form), finds out what type they manage bindings for and what control or controls they manage bindings to, and then call Refresh() on the latter, but before I attempted to automate all of it I'd be sure just to step back and think about it. I'm a strong believer in keeping things as simple as possible. That means making sure your problem merits a solution of the complexity you're undertaking.
 
Back to Top
MichaelNiemann View Drop Down
Newbie
Newbie


Joined: 12-Jul-2007
Posts: 10
Post Options Post Options   Quote MichaelNiemann Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jul-2007 at 7:51am
>> That means making sure your problem merits a solution of the complexity you're undertaking. <<

Greg, by all means. I was really just asking if the linking mechanism between the Persistence Manager -> BO -> UI was available [ asking as a newbie], for purposes such as fixing this DGV bug... or other more useful things.

Thank you for your response.

Mike
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 30-Jul-2007 at 10:14am

Gotcha. Most welcome!

Greg

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down