locked
Refresh parent search screen

    Question

  • Is there a way to refresh a collection on a parent search screen?

    I've tried using Application.ActiveScreens.OfType<ParentScreenType>().FirstOrDefault() but it keeps return null.

    Tuesday, April 12, 2011 9:04 PM

Answers

  • T_DeSanto, we are looking at that issue.

    Yann, his luck is good today.

    Steve

    • Marked as answer by T_DeSanto Wednesday, April 13, 2011 3:19 PM
    Wednesday, April 13, 2011 3:06 PM

All replies

  • Hi,

    Unfortunately the collection of ActiveScreens does not actually contain a set of Screen objects.  It contains a proxy class that you can use to access the actual screen object (this is due to different threads running in different threads).  Here is some sample code that achieves what you need.

          Microsoft.LightSwitch.Client.IActiveScreen searchScreen = Application.ActiveScreens.Where(a => a.Screen is SearchCustomers).FirstOrDefault();
          searchScreen.Screen.Details.Dispatcher.BeginInvoke(() => 
          {
            ((SearchCustomers)searchScreen.Screen).Customers.Refresh();
          });
    

     

    Tuesday, April 12, 2011 10:37 PM
  • Unfortunately, the only way you'll be able to refresh a collection *completely* is to refresh the WHOLE screen.

    There is currently a bug (although we're being told it's by design) in the grid where refreshing the collection only reflects added or deleted records, updates to records don't show up in a grid collection refresh.

    If you need updates to be reflected as well, & just about everyone would, it shows lack of real world requirements to think otherwise, here's how you refresh the whole screen:

        var parentScreen = Application.ActiveScreens.Where(a => a.Screen is ParentScreenType).FirstOrDefault();
          parentScreen.Screen.Details.Dispatcher.BeginInvoke(() =>
          {
            parentScreen.Screen.Refresh();
          });
     

    It's a workaround, & there are times where is has unexpected (or undesirable side-effects, like giving that screen focus), but it looks like one we're going to be stuck with, unfortunately.

    You can read more about this bug here http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/0bfb9028-307f-49c2-8d65-309443e2d653. It's been talked about a LOT.

    Yann

    Tuesday, April 12, 2011 11:06 PM
  • Will the refresh problem be fixed in the next update?
    Wednesday, April 13, 2011 12:58 PM
  • Good luck getting an answer on that..
    Wednesday, April 13, 2011 1:41 PM
  • T_DeSanto, we are looking at that issue.

    Yann, his luck is good today.

    Steve

    • Marked as answer by T_DeSanto Wednesday, April 13, 2011 3:19 PM
    Wednesday, April 13, 2011 3:06 PM
  • Hi Steve,

    Pehaps I phrased that wrong, lol.

    I didn't mean that I thought he wouldn't get a response at all (even though a couple of MY questions seem to have gone ununswered lately), I meant more that it was unlikley, from what we've heard from members of the team, that it would be changed any time soon & was considered to be "correct" behavior anyway.

    If I'm wrong & you guys have reconsidered the current B2 behavior as being potentially not acceptable after all, I'm very happy to be proved wrong.

    I hope your response was as light-hearted as mine was.

    Yann

    Thursday, April 14, 2011 12:44 AM
  • Yes, I was giving you a friendly tweak :-).

    To provide some transparency about the process, we actually discussed that issue a *lot* before beta 2, but weren't able to address it. One option was to leave it, as the current behavior isn't strictly wrong. We obviously agree that the requested behavior also makes sense, as we looked at it before beta 2.

    But as we're trying to lock down a produce a high quality product, people have to make some serious noise before we reopen issues, and even then sometimes we can't find a low risk, low cost way to address what they want. Also, runtime changes are riskier than design time changes, so they get double scrutiny.

    Telling people we're looking at stuff gets their hopes up, and explaining the complicated factors that go into a call against a feature (that we may also want) is nearly impossible at times (involving test coverage, size of fix allocation of people to other tasks, cascading dependencies that increase risk surface area, etc). It may seem that nothing is happening on some of these things, but I want you to know we are listening, greatly value the feedback and use it to make decisions.

    Steve

    Thursday, April 14, 2011 3:46 AM
  • Absolutely no problem, continue to "friendly tweak" away, lol. that was how I took it.

    Transparency is good! Documentation, & not having to waste our time (& maybe even sanity) finding/dealing with bugs that you guys already know about & may have even fixed, or features that had to be a certain way for a certain reason, would be even better.

    I *definitely* understand what you're saying though, & I freely admit that you're often stuck between a rock & hard place at times. It may not seem like it at times, but we're on the same side.

    What I DID mind, & took great exception to, was being told that it was perfectly OK to have additions/deletions reflected in a grid, but not "changes". We were being told it was "expected" & "acceptable" behavior, which hopefully we have now ALL made enough "serious noise" about for you guys to realise that our customers (& potentially YOUR customers as well, don't forget) won't be happy with this.

    I know my clients will NOT "get" that behavior, & I'll have to "try" to explain it to them. I wouldn't have objected so strongly if the response had been "we did what we had to do, to avoid potential silent data loss (which *eventually* came out) & we'll do everything we can to reinstate the previous (expected) behavior in a manner that will not damage data.

    I don't think any of us are "unreasonable", but some of the responses we've gotten (or often LACK of responses) have tended to escalate the frustration.

    Telling us that you're listening is one thing, SEEING that you're listening is another.

    Thanks for taking the time to get involved on the forum personally.

    Yann

    Thursday, April 14, 2011 4:20 AM
  • Well this issue was one of my my biggest peeves about b2.  Im sure you guys remember my monster "Grid Refresh Bug" post...lol  I really hope the team can come up with a better way to handle these scenarios..it's probably, aside from the lack of inheritance support, the most frustrating thing for me.
    Thursday, April 14, 2011 4:27 AM
  • Gberg,

    Talk to me about the lack of inheritance support. While they're probably out there, I've not read everything so I've not seen anyone comment on the subject. A specific example of where you'd use it would be useful too. (I understand all of the issues involved, I'm just asking for the specifics of your situation.)

    Steve

    Thursday, April 14, 2011 5:05 PM
  • Yann,

    I totally think we're on the same side--you guys are passionate that we build a successful product. We're partners in that. Thanks for your input.

    Steve

    Thursday, April 14, 2011 5:06 PM
  • There is currently a bug (although we're being told it's by design) in the grid where refreshing the collection only reflects added or deleted records, updates to records don't show up in a grid collection refresh.

    You can read more about this bug here http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/0bfb9028-307f-49c2-8d65-309443e2d653. It's been talked about a LOT.

    Yann

    Please, let's dig deeper into this topic together.

    It is a requirement that all grid functions work with saved and unsaved data exactly the same.  Sorts, filters, work with collection values, etc.

    Logically, we have a conflict in definition and usage within LS with the term "refresh".

    A refresh to a Screen requires that ALL data in the Screen DataWorkSpace has been saved or discarded.

    However a refresh to a Collection DOES NOT require any updates.   The purpose of a Collection refresh is to "do" something that is NOT clear to the community.  So let's get a clear definition:

    Applying the implicit definition of "refresh" to the Collection, we would expect that all original values for the collection would be refreshed and all values changed by the user would be intact.  Simple.  Can we all agree on this?  Anything that doesn't comply with this definition would be a bug.  In my mind, this doesn't tough to accomplish. 

    Geoff's reference post (yes, we need something better than a forum format for our collaborative work here) also addresses parts of this topic. 

    I would also like to ask Telerik to officially join our LS forum on topics like this.  Telerik is the first commercial component vendor to support LightSwitch.  I hope that others (DX, Intersoft, Infragistics, etc.) will also join in.  The more great minds we have working on LS/SL, SharePoint, and ASP.NET (Razor - my plug), the better life will be.  Specifically, commercial components MUST function with the same technology based on the definition of an LS refresh.

    Though

    Thursday, April 14, 2011 8:17 PM
  • @Steve,

    Yann, Geoff, and I will start a new post to move forward with inheritance and reusable code.

    I have addressed it with previous posts recently regarding Modal Windows.

    Thursday, April 14, 2011 8:20 PM
  • Yann,

    I totally think we're on the same side--you guys are passionate that we build a successful product. We're partners in that. Thanks for your input.

    Steve

    Aside from being great loving individuals opening our hearts and minds to improve life globally, we are also business people.   We need the best possible LS/SL and .NET to make some good bucks.  ASAP!  We've been waiting patiently since last August.

    I'll bet Xander and Derek are with us on this one, yes?

    Thursday, April 14, 2011 8:27 PM
  • "Successful product" includes being financially viable for those involved.

    "Best possible" and "ASAP" are fundamentally in tension.

    Your impatient patience is a good thing--it means you think LS can be part of a successful business for you and you want to get on with it.

    Steve

    Thursday, April 14, 2011 9:11 PM
  • in an effort to keep this thread clean...i revived this old thread i made re: inheritance:

     

    http://social.msdn.microsoft.com/Forums/en-US/lightswitchgeneral/thread/e5fe77cb-1bfd-4629-b9e9-d3b8d63bfb66

    Friday, April 15, 2011 12:54 AM
  • Hi all

     

    In this blog:

     

    http://blogs.msdn.com/b/lightswitch/archive/2010/11/17/communicating-across-lightswitch-screens.aspx

     

     Sheel Shah, explains in clear and simple as in LightSwitch Refresh. And it works perfect.

     

    Jaime

    Saturday, June 25, 2011 11:20 PM