-
Notifications
You must be signed in to change notification settings - Fork 764
clr-datagrid should not call clr-dgRefresh when it gets Destroyed/Initialized. #1099
Comments
Our previous solution actually emitted too late, which broke server-driven datagrids that relied on the `[clrDgLoading]` input. Also fixes vmware-archive#1099 as a nice side-effect. Signed-off-by: Eudes Petonnet-Vincent <epetonnetvince@vmware.com>
After investigation, it appears this is blocked by angular/angular#14252. Because |
Sadly, this will not be fixed with #2094. What #2094 will do is just offer a single input for the datagrid state, which will either solve or be a good compromise for many requests. The fact that on destroy, the datagrid emits a state without filters/pagination/sorting is something that is truly blocked until Angular fixes the linked issue. We have absolutely no way to handle it on our side. 😢 Your best bet is to have some flag on the component that uses a datagrid, set that flag to |
I took the time to write a quick StackBlitz showing what I mean: https://stackblitz.com/edit/datagrid-track-state?file=app%2Fapp.component.ts On the application side, your flag is always updated before the "wrong" events fire. So you can just ignore them. The problem is that on our side, we have no way to distinguish the filter itself being destroyed from the whole datagrid being destroyed. So the event will go through every time. |
Hi Guys, When will this be fixed? |
As mentioned in my previous comment, we cannot fix this until Angular fixes angular/angular#14252. This is out of our hands at the moment, we cannot give you an ETA on a fix for Clarity. |
@youdz Understood, sorry I missed the info. It's not a problem for me if it's called on destroy, however the object is not correct in that call. Filter property of ClrDatagridStateInterface is undefined in that call (should not be because I set a one or more filter values) , sort and paging is there. Other clrdgRefresh calls are fine, but somehow in ondestroy filter values have been lost somewhere. If I create a separated defect and a stackblitz, is there any chance that it will be fixed, or you won't have time for this in this century? :) |
Your problem is exactly the one posted here, sadly. To give you a better idea, the order of events is:
If the Angular issue I linked was fixed, step 4 would happen before step 2, and we could ignore state changes because we know the entire datagrid is up for destruction. The workaround until then would be for you to ignore events after scheduling the Datagrid's destruction. If you're willing to create a Stackblitz like you proposed, I'd be happy to update it to show you what I mean with this workaround. 👍 EDIT: Actually, I already posted a StackBlitz showing this in the thread: https://stackblitz.com/edit/datagrid-track-state?file=app%2Fapp.component.ts |
Thanks for the clarification and help @youdz |
I swear I'm going crazy. I'll update with the workaround as soon as I have some more time today. EDIT: on top of this the destruction in your case happens through routing, so you're even more dependent on the Angular issue I posted above and the workaround becomes dirtier, having to listen to the router to check if that's the source of the destruction. 😞 |
You observation is perfect, it does the same to me. XD |
The two-way binding would work the same way, it's just an input + an output, and we already have the output. We have an open issue (#2094) to add the input, just haven't gotten around to it yet. So that wouldn't solve your problem at all. So here is your StackBlitz with the workaround, correctly saving the state even with a route change: https://stackblitz.com/edit/clr-filter-settings-save-with-workaround?file=src/app/grid-component/grid-component.component.ts I subscribe to route changes (I used |
Rock solid, works like a charm. |
Another issue came up with this, I have to preset the filtervalues when we are navigating back to the grid. I can see that we can preset the string filters like this: String filtering |
Thats exactly #2094, which we don't have yet. An external contributor apparently tried to work on it and hit several issues he couldn't solve, so it doesn't look like it's going in in the short term, sorry. |
Understood, I just wanted to be sure, this is the only way. Thanks! |
Would it be possible to destory the datagrid manually before making an action and catch that error? I just stumbled over that behaviour. |
@youdz Is there any workaround for datagrids in tabs? It seems like clr-dgRefresh is being called first before the two-way bound variable of a tab content is set. I am using the variable that has a binding to clrIfActive directive of a tab content and use that as a flag to disable auto refresh of the datagrid. Unfortunately, clr-dgRefresh is always called first. I have two tab panels with each panel contains a data grid. Switching from one tab to another refreshes both grids and sends two http requests. |
@whizkidwwe1217 Best to open a stack overflow question with a demo of what you're doing rather than get the ticket off topic. |
Hi Fellas, I was working with Datagrid and found this issue :( The idea is to add a debounce in between |
@hippee-lee : Thoughts? |
There is a workaround available for this issue, and we recommend using it for Clarity Angular. As we build Clarity Core implementations, we expect that this issue won’t be an issue. To help us clean up our backlog, we are going to close this with a functional workaround available and suggest you follow updates for Clarity Core for enhancements that can support your use case with Clarity Core components. |
Logged the workaround/pattern in our support db. |
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary. |
Select one ... (check one with "x")
Expected behavior
Hi, I am facing problem with clr-datagrid. It calls clrDgRefresh multiple times whenever gets destroyed. Is it expected behaviour ?
When i did some research, found that it calls clrDgRefresh for all Active Filters whenever gets destroyed.
Small Analysis: clr-datagrid calls unsubscribe when gets destroyed which in-turn calls unregisterFilters which finally calls clrDgRefresh for all active filters.
I believe clrDgRefresh should even not get called when initialize clr-datagrid. This is not directly related to this issue. But please consider this scenario as well.
Actual behavior
clrDgRefresh gets called for all Active filters when clr-datagrid destroys.
Reproduction of behavior
Steps to Reproduce:
1.) Create clr-datagrid(would be good if with custom filter).
2.) In UI, filter on multiple column(you just need to make multiple filters isActive() to return true)
3.) Do something that destroys clr-datagrid(may be with a button)
4.) clrDgRefresh gets called for every filter which has isActive() true.
Templates:
Environment details
Angular version: 2.0.X
Clarity version:
OS and version:
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
The text was updated successfully, but these errors were encountered: