Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Export Client Data won't hide field

    Using:

    SmartGWT-power-3.1.p20130111
    GWT 2.5



    Hello.
    I’m trying to export the client data of a com.smartgwt.client.widgets.grid.ListGrid component, to a XLS file.
    The export process is ok, except when I try to hide some field.
    Is there 2 ways to hide a field:
    1- Using the method setCanExport(false), that would hide that selected field to export.
    2- Using the method setExportFields(“f1”, “f2”...), that would not export fields not sent as parameters.


    ----------------------------------------------------------------
    When I try to use the first option (setCanExport), it is just ignored. Don’t matter the value in parameter. Even false or true, the field is always exported, anyway.

    Code:
    	private void setGridFields() {
    		ListGridField F1 = new ListGridField("F1", "F1");
    		ListGridField F2 = new ListGridField("F2", "F2");
    		ListGridField F3 = new ListGridField("F3", "F3");
    		
    		/* it doesn't work */
    //		F1.setCanExport(false);
    		
    		this.grid.setFields(F1, F2, F3);
    
    	}
    ----------------------------------------------------------------
    The second option (setExportFields), works partially. If I have a grid with 3 fields, and set only field 1, and field 2, to export, it works perfectly. But, if I set the field 2 and field 3, it doesn't works. The body of the grid is exported perfectly (hiding the field), but the header, still occupying the cell of the hidden field.

    Code:
    		
    		/* it works */
    //		dsRequest.setExportFields(new String[]{"F1", "F2"});
    		
    		/* it doesn't works */
    //		dsRequest.setExportFields(new String[]{"F2", "F3"});

    ----------------------------------------------------------------
    The complete class:

    Code:
    package br.com.cit.sandbox.client.tracking.history;
    
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.types.ExportDisplay;
    import com.smartgwt.client.types.ExportFormat;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.toolbar.ToolStrip;
    import com.smartgwt.client.widgets.toolbar.ToolStripButton;
    
    public class HistoryGridView extends VLayout {
    
    	private ToolStrip tools = new ToolStrip();
    	final ListGrid grid;
    
    	public HistoryGridView() {
    		grid = new ListGrid();
    
    		setGridData();
    		setGridFields();
    		setExportAction();
    		
    		setWidth("100%");
    		setHeight("100%");
    		addMember(grid);
    
    		this.setAttribute("", true, true);
    	}
    
    
    	private void setGridData() {
    		Record r1 = new Record();
    		r1.setAttribute("F1", "F1");
    		r1.setAttribute("F2", "F2");
    		r1.setAttribute("F3", "F3");
    
    		Record r2 = new Record();
    		r2.setAttribute("F1", "G1");
    		r2.setAttribute("F2", "G2");
    		r2.setAttribute("F3", "G3");
    
    		Record r3 = new Record();
    		r3.setAttribute("F1", "H1");
    		r3.setAttribute("F2", "H2");
    		r3.setAttribute("F3", "H3");
    
    		Record[] recs = { r1, r2, r3 };
    
    		this.grid.setData(recs);
    	}
    
    	private void setExportAction() {
    		final ToolStripButton export = new ToolStripButton("Export");
    
    		export.addClickHandler(new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    				DSRequest dsRequest = new DSRequest();
    
    				dsRequest.setExportAs(ExportFormat.XLS);
    				dsRequest.setExportDisplay(ExportDisplay.DOWNLOAD);
    				dsRequest.setExportDelimiter(";");
    				dsRequest.setExportFilename("TEST");
    				
    				/* it works */
    //				dsRequest.setExportFields(new String[]{"F1", "F2"});
    				
    				/* it doesn't works */
    //				dsRequest.setExportFields(new String[]{"F2", "F3"});
    				
    				grid.exportClientData(dsRequest);
    
    				tools.addButton(export);
    
    			}
    		});
    
    		addMember(export);
    	}
    
    	private void setGridFields() {
    		ListGridField F1 = new ListGridField("F1", "F1");
    		ListGridField F2 = new ListGridField("F2", "F2");
    		ListGridField F3 = new ListGridField("F3", "F3");
    		
    		/* it doesn't work */
    //		F1.setCanExport(false);
    		
    		this.grid.setFields(F1, F2, F3);
    
    	}
    
    }
    Attached Files

    #2
    Thanks for the notification. We're taking a look. In the meantime, it sounds like you have a workaround you can use in your application (explicitly specifying the fields).

    We'll let you know when we have more information.

    Regards
    Isomorphic Software

    Comment


      #3
      Thanks for your attention.
      Yes, we have a workaround, but as I said, it works partially :-(
      I need to hide the first field of the grid. Using the 'workaround', it exports the body of the field hidden, but the header, occupies the cell where the title must to be. It is shown in the images attached in the first post.

      Comment


        #4
        This is currently under investigation - we expect to have a resolution in the next few days.

        Regards
        Isomorphic Software

        Comment


          #5
          Hello!

          Any news about this issue?
          Thank you!

          Comment


            #6
            This issue should already be fixed in the latest nightly build (and we're not seeing it in our testing).
            Can you please re-test against the latest and let us know if the problem is still happening for you

            Thanks
            Isomorphic Software

            Comment

            Working...
            X