PDA

View Full Version : How do I make a grid 'render' before it's visible?



bseddon
21 Jan 2013, 5:31 PM
Suppose there are a pair of grids on two different tabs. Neither will be rendered until they are made visible (the event viewReady is only fired once a grid is visible).

I want to be able to update the second grid which is currently hidden because it's on another tab and has not yet been rendered. These are row level (not cell-level) updates to the second grid which are to, for example, change row colors based on the selections in the first, currently visible, grid or set a row's error qtip attributes. That is, these are run-time updates, not ones that can be preconfigured or stored as persistent data.

At the moment I'm not able to perform these changes until the hidden grid has been displayed at least once. Until then the grid has not been rendered so the DOM elements representing the row do not exist which means it is not possible to adjust them.

If only classes need to change, then it is possible to override getRowClass and return the required classes based on some criteria. However as I want to set other attributes (such as 'data-errorqtip') then overriding getRowClass is not sufficient. It is possible to listen for the event 'afterRender' and update the attributes here but then I have code to implement a single business rule in two different location.

So it will be great if someone is able to tell me how I can force a grid to render (even though it is hidden) so then I am able to change the DOM elements for the row in one place.

Thanks

Bill Seddon

mitchellsimoens
23 Jan 2013, 10:41 AM
You can have it as a child item of another container or use renderTo config but also set the hidden config to true so it won't be visible.