-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Dynamic handling of grid options, and document how to avoid watchers (ng-if, ng-class, ng-show etc) #1819
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
Comments
In a sense #1792 might be an example of this - we don't want every bit of code creating it's own watch on the options, it'd be nice if we could have a pattern where we could just write an evaluation function that decides whether or not to show the footer, and register it to be dependent on the options. Whenever the options change the grid would automatically re-evaluate that function. |
Add a dataChangeCallback capability to grid, which is called by the data watch function. Make use of this for importer to know when the data change has occurred. Refer angular-ui#1819 for the concept here. Fix rowEdit so that error rows aren't duplicate entered into rowEditRowsDirty if they error twice. Update tutorial numbering - newer tutorials have conflicted with older. Change importer to require an explicit callback to be provided by the user - change the data from userspace rather than in the grid itself. Fix grid menu so that it displays correctly on Chrome, it had started only partially rendering. Fixed by changing position from absolute to fixed.
I needed something along these lines to provide dynamic column header classes - a method to notice that something had changed that might impact headers. I also applied this to cell class. The logic behind it is to create a set of dataChangeCallbacks on the grid (refer Interested in a review of this approach and whether people think it looks good. |
Elements of the documentation are now there, there are just a number of places where we still don't dynamically honour options cleanly. The majority of them are dealt with, but not all them. |
Where can I find this documented? |
The point of the open issue is kinda that it's not already documented and it'd be good if it was. |
Been wondering about these: |
Any advances? |
I think there should definitely be some documentation added to address this. Copying Paul's answer from: #2417 "Many of the grid features aren't dynamic - they are set on grid creation and not updated when you change the options. I would expect this to be another example, there is a description in #1819" This would have saved me some time when I tried to reason why I could disable filtering later on (i.e. outside gridoptions instantiation), but could not enable filtering later on--it is just not supported in any case. I can post the code later if anyone is interested |
When I started on the project I was surprised at how much hand-rolled code there was - click event handlers and the like. I generally followed the pattern, but without understanding why. I now understand that it is a deliberate strategy to avoid the performance impacts of large numbers of watches being fired on every digest cycle.
What would be great is to create some documentation for new contributors on:
a) Why we do this
b) The common patterns - so if you would have used an ng-show, you should instead do a compile or an append in the specific circumstance you need
c) Common gotchas, so if we hand roll then we need to have handlers for the common triggers - if you are simulating an ng-class, then you need to recalculate it whenever the data changes
I also wonder whether we could add some helper methods, or registration functions, or something (or perhaps we already have these and they're the column builders etc which should be getting reused). My thought here is that once we write down the patterns, we'd suddenly see that we have a bunch of items that we'd like to reevaluate whenever the data changes. Ideally we'd have a single data watch / registration thing that holds a list of registered functions that should be called when it observes a data change (or even that gets called centrally by anything that changes data, such as the edit feature).
If we got this right, we could simplify this whole process into a standard set of registrations that people use to get the equivalent of an ng-show, an ng-if etc. Basically it'd be a helper function that took a template and a condition, and some information about what events require a reevaluation of the condition. It would be like a custom angular - so it still takes the load off the developer, but the triggers for reevaluation are much more tailored than just "every digest cycle re-evaluate the whole thing".
The text was updated successfully, but these errors were encountered: