tudor-malene/Easygrid — pull request #131 by PeterGok (2014-12-04 17:56:53+00:00)
Title: EasyGrid Grid Map Definitions

Hey Tudor, I'm a fellow dev who has been using your EasyGrid plugin for a little while now. I came across a use case where I had to create grids dynamically, and I thought of a solution to store them in a map and call initGrids() method in EasygridInitService whenever I updated the map. This is just a suggestion and you know your code base a lot better, so feel free to let me know if there are any better solutions.

This is how an example map would be defined (ends in GridMap):
```groovy
private Map whitelistingGridMap = new HashMap()
```
The map would contain the grid names that map to their closures. This also allows for dynamic insertion of variables into the closure. For example, experimentName is used to set the attribute name dynamically to find the object in the session:
```groovy
whitelistingGridMap.put(experimentName + "whitelistGrid", {
dataSourceType 'list'
gridImpl 'jqgrid'
attributeName experimentName + '.configuration.current.channelWhitelists'
enableFilter true
inlineEdit true
saveRowClosure { gridConfig, inlineResponse ->
ArrayList channelWhitelists = session.getAttribute(experimentName)?.configuration.current.channelWhitelists
...
```