Announcement

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

    Problem while exporting client data from ListGrid

    Hello,

    I am using SmartClient Version: v8.3p_2013-02-26/Enterprise Deployment (built 2013-02-26) and have a problem on exporting client data from Listgrid.

    Another question regarding background color. Is there anyway to exporting ListGrid data with background color of each cell? you may refer to attached screen shot.

    Please refer to code below for initiating ListGrid.

    Code:
    ListGrid listGrid = new ListGrid() {
    			@Override
    			protected String getBaseStyle(ListGridRecord record, int rowNum, int colNum) {
    				String platform = record.getAttributeAsString("platform");
    
    				if (colNum == 7 && platform.indexOf("TOTAL") == -1 && !platform.equals("Owned CIMitar") && !platform.equals("Consigned CIMitar")) {
    					return "myBoxedGridCellGreen";
    				} else if (platform.endsWith("TOTAL") && !platform.equals("OVERALL TOTAL")) {
    					return "myBoxedGridCellYellow";
    				} else if (platform.equals("Owned CIMitar") || platform.equals("Consigned CIMitar") || platform.equals("OVERALL TOTAL")) {
    					return "myBoxedGridCellGray";
    				} else if (colNum >= 10) {
    					if (colNum < 15) {
    						if ((colNum == 10 && record.getAttributeAsDouble("exDown") > 3.0D) || (colNum == 11 && record.getAttributeAsDouble("diffFt") > 3.0D)
    								|| (colNum == 12 && record.getAttributeAsDouble("diffRe") > 3.0D) || (colNum == 13 && record.getAttributeAsDouble("diffQa") > 3.0D)
    								|| (colNum == 14 && record.getAttributeAsDouble("handling") > 3.0D)) {
    							return "myBoxedGridCellLimit";
    						}
    					} else if (colNum >= 15) {
    						if ((colNum == 15 && record.getAttributeAsDouble("retest") > 5.0D) || (colNum == 16 && record.getAttributeAsDouble("qa") > 5.0D)
    								|| (colNum == 17 && record.getAttributeAsDouble("handler") > 5.0D) || (colNum == 18 && record.getAttributeAsDouble("material") > 5.0D)
    								|| (colNum == 19 && record.getAttributeAsDouble("engr") > 5.0D) || (colNum == 20 && record.getAttributeAsDouble("setup") > 5.0D)
    								|| (colNum == 21 && record.getAttributeAsDouble("tester") > 5.0D) || (colNum == 22 && record.getAttributeAsDouble("noSchd") > 5.0D)
    								|| (colNum == 23 && record.getAttributeAsDouble("pmCal") > 5.0D) || (colNum == 24 && record.getAttributeAsDouble("noWork") > 5.0D)
    								|| (colNum == 25 && record.getAttributeAsDouble("hdTem") > 5.0D) || (colNum == 26 && record.getAttributeAsDouble("other") > 5.0D)
    								|| (colNum == 27 && record.getAttributeAsDouble("excludeMatlEX") > 5.0D)) {
    							return "myBoxedGridCellLimit";
    						}
    					}
    				}
    				return super.getBaseStyle(record, rowNum, colNum);
    			}
    		};
    
    		listGrid.setAutoFitData(Autofit.HORIZONTAL);
    		listGrid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
    		listGrid.setCanAutoFitFields(false);
    		listGrid.setCanSort(false);
    		listGrid.setCanGroupBy(false);
    		listGrid.setCanPickFields(false);
    		listGrid.setAutoFitFieldWidths(true);
    		listGrid.setCanSort(false);
    		listGrid.setCanFreezeFields(false);
    		listGrid.setBaseStyle("myBoxedGridCell");
    		listGrid.setCellHeight(15);
    		listGrid.setOverflow(Overflow.AUTO);
    		listGrid.setShowEmptyMessage(true);
    		listGrid.setEmptyMessage("No items to show");
    		listGrid.setWidth100();
    		listGrid.setHeaderHeight(55);
    		listGrid.setHeaderSpanHeight(20);
    		listGrid.setHeight(500);
    
    		ListGridField platformField = new ListGridField("platform", "Platform");
    
    		ListGridField totalCountField = new ListGridField("totalCount", "T-CNT");
    
    		ListGridField workingHourStdField = new ListGridField("workingHourStandard", "STD");
    
    		ListGridField workingHourActlField = new ListGridField("workingHourActual", "ACTL");
    
    		ListGridField arhField = new ListGridField("arh", "ARH");
    
    		ListGridField prodUnitStdField = new ListGridField("prodUnitStandard", "STD");
    
    		ListGridField prodUnitrActlField = new ListGridField("prodUnitrActual", "ACTL");
    
    		ListGridField utilizationField = new ListGridField("utilization", "Utili<br>zation");
    
    		ListGridField efficiencyField = new ListGridField("efficiency", "Effi<br>ciency");
    
    		ListGridField utilEffiField = new ListGridField("utilEffi", "Util-<br>Eff");
    
    		ListGridField exDownField = new ListGridField("exDown", "EX<br>Down");
    
    		ListGridField diffFtField = new ListGridField("diffFt", "Diff-<br>FT");
    
    		ListGridField diffReField = new ListGridField("diffRe", "Diff-<br>Re");
    
    		ListGridField diffQaField = new ListGridField("diffQa", "Diff-<br>QA");
    
    		ListGridField handlingField = new ListGridField("handling", "Hand<br>ling");
    
    		ListGridField retestField = new ListGridField("retest", "Retest");
    
    		ListGridField qaField = new ListGridField("qa", "QA");
    
    		ListGridField handlerField = new ListGridField("handler", "Handler");
    
    		ListGridField materialField = new ListGridField("material", "Matl.");
    
    		ListGridField engrField = new ListGridField("engr", "Engr");
    
    		ListGridField setupField = new ListGridField("setup", "Setup");
    
    		ListGridField testerField = new ListGridField("tester", "Tester");
    
    		ListGridField noSchdField = new ListGridField("noSchd", "NO_<br>Schd");
    
    		ListGridField pmCalField = new ListGridField("pmCal", "PM/<br>CAL");
    
    		ListGridField noWorkField = new ListGridField("noWork", "NO_<br>Work");
    
    		ListGridField hdTemField = new ListGridField("hdTem", "HD/<br>TEM");
    
    		ListGridField otherField = new ListGridField("other", "Other");
    
    		ListGridField excludeMatlExField = new ListGridField("excludeMatlEX", "Exclude <br>Matl/EX");
    
    		listGrid.setFields(platformField, totalCountField, workingHourStdField, workingHourActlField, arhField, prodUnitStdField, prodUnitrActlField, utilizationField,
    				efficiencyField, utilEffiField, exDownField, diffFtField, diffReField, diffQaField, handlingField, retestField, qaField, handlerField, materialField, engrField,
    				setupField, testerField, noSchdField, pmCalField, noWorkField, hdTemField, otherField, excludeMatlExField);
    
    		listGrid.setHeaderSpans(new HeaderSpan("PLATFORM", new String[] { "platform", "totalCount" }), new HeaderSpan("WORKING HOUR", new String[] { "workingHourStandard",
    				"workingHourActual", "arh" }), new HeaderSpan("PRODUCT UNIT", new String[] { "prodUnitStandard", "prodUnitrActual" }), new HeaderSpan("(%)", new String[] {
    				"utilization", "efficiency", "utilEffi" }), new HeaderSpan("DOWNTIME(%) By CIMitar", new String[] { "exDown", "diffFt", "diffRe", "diffQa", "handling" }),
    				new HeaderSpan("DOWNTIME(%) By Scops Manual Entry", new String[] { "retest", "qa", "handler", "material", "engr", "setup", "tester", "noSchd", "pmCal", "noWork",
    						"hdTem", "other" }), new HeaderSpan("CDT", new String[] { "excludeMatlExField" }));
    And refer to code below for exporting client data.

    Code:
    ImgButton biSave = new ImgButton();
    biSave.setSize(24);
    biSave.setShowRollOver(false);
    biSave.setActionType(SelectionType.BUTTON);
    biSave.setSrc(Constants.IMAGE_EXCEL_24);
    biSave.setTooltip("Save as CSV");
    biSave.setShowDown(false);
    biSave.addClickHandler(new ClickHandler() {
    
    	@Override
    	public void onClick(ClickEvent event) {
    
    		DSRequest dsRequestProperties = new DSRequest();
    		dsRequestProperties.setOperationId("customExport");
    		dsRequestProperties.setExportAs(ExportFormat.OOXML);
    		dsRequestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
    		dsRequestProperties.setExportFilename(labelTitle.getContents());
    				dsRequestProperties.setExportDatesAsFormattedString(true);
    				listGrid.exportClientData(dsRequestProperties);
    			}
    		});
    When I saved data of ListGrid, It is saved well but Headerspan titles aren't aligned well with header. As you can see in the attached file, from headerspan (%), it isn't aligned with headers.

    Please, let me know how I can aligned it.

    Thanks.
    Attached Files
    Last edited by nk; 5 Mar 2013, 21:16.

    #2
    We don't try to send the entire CSS style to Excel (it can't handle that), but if you use hilites to change the background or foreground colors, those will be sent.

    As far as the headerSpans and alignment, it looks like alignment and headerSpans work until you hit the headerSpan titled "(%)". Can you try giving that a normal name (setName("percent")) and see if that corrects the issue?

    Comment


      #3
      Regarding headerspan title

      Hi Isomorphic,

      I followed your suggestion but result is same.
      Please let me know how I can fix it.

      Thanks.

      Comment


        #4
        We cannot reproduce this problem of misaligned headerSpans. To look into it further, we will need a standalone test case that demonstrates the problem.

        Comment


          #5
          Problem while exporting client data from ListGrid

          Hi Isomorphic,

          I found a problem by myself and it was using HTML (<br>) in title of ListGridField. You may see my code below.

          ListGridField utilizationField = new ListGridField("utilization", "Utili<br>zation");

          Please just confirm that if I can use HTML for title of ListGridField or not.

          The reason why I used HTML is to display titile with carriage return (to reduce width of ListGridField)

          Comment


            #6
            Yes, it's legal to use HTML in the title of a ListGridField.

            Your results suggest that we'll need to do some escaping of the string before it's passed to Excel, to avoid Excel interpreting the HTML wrongly in some way. We'll look into this.

            Comment


              #7
              Hi Isomorphic,

              Thanks for prompting reply.
              Please let me know once your engineers fix it.

              Comment


                #8
                This is fixed now - you may download next nightly build and try it out.

                Comment


                  #9
                  Hi, It's working well now.
                  Thanks for your update!

                  Comment

                  Working...
                  X