Announcement Announcement Module
Collapse
No announcement yet.
Export Selected Rows of a Grid. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Export Selected Rows of a Grid.

    Hi everyone,

    I'm new in Grails, and I'm developing an application which export a selected rows of a grid to excel. For this I am using Grails 2.2.0, Easygrid plugin 1.3.0, Export plugin 1.5, jQuery plugin 1.8.3 and jQuery-ui plugin 1.8.24.

    I would like to add a column "Export" with a checkbox per row, but I don't know how to do it through plugins.

    Actually, I have this:

    Attachment

    My code for the grid and export is this:

    Controller:

    Code:
     ....
    	static grids = {
            
            resumenGrid {
    
                dataSourceType 'gorm'
                domainClass Resumen
    
                columns {
                    id {
                        type 'id'
                    }
                    item
                    descripcion
                    unidad
                    exporta
                }
            }
        }
    
    .....

    View:

    HTML Code:
    <html>
    <head>
        <meta name="layout" content="main">
        <title>Resumenes</title>
        <r:require modules="easygrid-jqgrid-dev,export"/>
        <nav:resources/>
    </head>
    
    <body id="resumen">
    <div id="menu">
        <nav:render group="tabs"/>
    </div>
    <grid:grid name="resumenGrid" jqgrid.width='958' columns.id.jqgrid.formatter='customShowFormat'
               jqgrid.caption='"Resumenes"' addUrl="${g.createLink(controller: 'resumen',action: 'add')}"/>
    <grid:exportButton name="resumenGrid"/>
    
    </body>
    
    <r:script>
    
            function customShowFormat(cellvalue, options, rowObject) {
                return "<a href='${g.createLink(controller: "resumen", action: "show")}/" + cellvalue + "'>" + cellvalue + "</a> ";
            }
    
    </r:script>
    <jq:jquery>
        console.log(jQuery('#resumenGrid_table').jqGridMethod('setSelection', 1));
    </jq:jquery>
    </html>


    ┐Can I add a checkbox in a grid (row/column) through plugins (Easygrid and Export) which represent a boolean attribute? ┐How to? Or ┐Can I export selected rows through "multiselect"? ┐How to?



    Thank you for any help.
    Attached Files

  • #2
    You will need to somehow submit the selected rows when you click the export button ( check out the jqgrid documentation for this ). It can be done with some javascript code.

    On the server-side, you will need to create a new Export Service . Basically you will need to start from EasygridExportService - which is the default one, and filter the data to be exported using the selected rows you submitted .
    The new export service can be specified when you declare the Grid.
    For example in your case:

    Code:
      resumenGrid {
    
                dataSourceType 'gorm'
                domainClass Resumen
                
                export{
                  exportService CustomMultiselectExportService
                }
                
                 jqgrid{
                 multiselect true    
                 }      
    
                columns {
                    id {
                        type 'id'
                    }
                    item
                    descripcion
                    unidad
                    exporta
                }
            }

    Comment

    Working...
    X