Search code examples
grailskendo-gridexport-to-excelexport-to-pdf

Grails export table to file with sort and filtration


I am using Grails with KendoGrid in the project and I would like to export info from my table. I`m using such thing in gsp file and It works fine:

<grid:exportButton name='entity'/> 

with nothing in controller, or

<export:formats action="list" formats="['csv', 'excel', 'ods', 'pdf', 'rtf', 'xml']"/> 

with

def list = {
params.max=20
        if (params?.format && params.format != "html") {
            response.contentType = grailsApplication.config.grails.mime.types[params.format]
            response.setHeader("Content-disposition", "attachment; filename=terminal.${params.extension}")

            exportService.export(params.format, response.outputStream, Entity.list(),[:], [:])
        }
    }

However, I have a task to export table filtered and sorted and now I have no idea how to accomplish it. I have tried using params tag like

<grid:exportButton name='terminal'  params="[sort: params?.sort, order: params?.order]" />

but in does not work. Any help, please?


Solution

  • Solved using export:formats and customising criterias in action`s method manually