-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you refresh the grid? #26
Comments
I tried turning off the cache, but that didn't work.
|
So is there no way to refresh the grid when new data arrives? The only way I've been able to make it work is by tearing down my entire NSHostingController, removing the view, then re-creating the NSHostingController and the SwiftUIView that contains the Grid and sending the data into it again. But it works fine with LazyVGrid, just not with this Grid component. It just always shows the first piece of data that was passed to it. There must be a better way to refresh the grid when new data is sent to my SwiftUI view. |
So I noticed that the layout cache is for iOS only. I'm working on a Mac app at the moment. So the cache shouldn't affect me. But why actually is the cache only for the iOS version? Just curious. I'm still not understanding why I'm not seeing any new data appear on screen when I pass in new data. Yet with LazyV/HGrid, it does work to show new data. |
Ok, so I'm going to post my code that I'm working with. If anyone sees anything wrong with my approach I'd love to know what I'm doing wrong. Basically I have a list of objects I'm iterating over and depending on their types, I'm generating different kinds of views. When I pass in new data into the Maybe this has something to do with Grid, I'm not sure. All I know is if I change to LazyVGrid, it works. But I don't get the layout I want. Any ideas?
|
So I found that if I add Is there a better solution? |
Is this project dead though? Not one response. Hmm... |
Hey @brendand, no, the project isn't dead, but unfortunately we do not have time right now to address this issue. But rest assured we will most certainly address this once we find time. Have a nice day |
Hi @f3dm76 Thanks so much for your response. That's good to know. Using the random |
I'm going to close this issue because as I was working on other refresh problems with my SwiftUI layout (non Grid related), I learned more about Swift and found a better way of gathering the objects that I wanted to render from my Core Data object store. I had almost given up on Grid and was using LazyVGrid, but decided to give Grid another chance and low and behold, the refresh was working now without having to generate a random Previously I was just looping through an array of Core Data objects directly, then calling a custom bind function to get and set the values. Now I build a Swift array of structs out of those Core Data objects and iterate over those. That seems to have done the trick. |
Hi @brendand have you by any chance come across the removal of items from LazyVGrid? |
Hi @Medef I haven't done anything with this in a while actually. Still using Grid, but haven't actually looked at in in a while. I'll get back to it eventually once I'm finished with some updates to my underlying data model. |
I have a macOS app that I'm adding Grid to, but when I pass in new data, the grid is not refreshed.
However, if I switch to using LazyVGrid, it does refresh. So I know the data is getting to the SwiftUI view. I'm integrating Grid using an NSHostingController and I'm monitoring changes to my object using @ObjectBinding. Anything outside the Grid will update when I change objects, but anything within the Grid does not.
Think of a master/detail view. The master is an AppKit NSTableView that shows a list of records. The detail view is my SwiftUI view that's using Grid to display a list of fields on screen. But when I switch records, the SwiftUI view's Grid never refreshes.
The text was updated successfully, but these errors were encountered: