Easygrid icon indicating copy to clipboard operation
Easygrid copied to clipboard

EasyGrid Grid Map Definitions

Open petergok opened this issue 10 years ago • 0 comments

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):

private Map whitelistingGridMap = new HashMap<String, Closure>()

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:

whitelistingGridMap.put(experimentName + "whitelistGrid", {
                dataSourceType 'list'
                gridImpl 'jqgrid'
                attributeName experimentName + '.configuration.current.channelWhitelists'
                enableFilter true
                inlineEdit true
                saveRowClosure { gridConfig, inlineResponse ->
                    ArrayList<ChannelWhitelist> channelWhitelists = session.getAttribute(experimentName)?.configuration.current.channelWhitelists
                    ...

petergok avatar Dec 04 '14 17:12 petergok