Announcement

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

    Export field titles

    SmartClient_SNAPSHOT_v90d_2013-04-05

    All browsers

    I have a datasource with fields that do not define the title attribute. This is because I use a dynamic async method to retrieve custom column titles based on the users login (users are part of companies which use different terminology for business objects. The implementation works correctly - the grid displays the correct titles for each user.

    However, when using exportClientData for XLS exports, the column headers are the field name, which is the correct behavior since the datasource config does not set titles.

    Can I override the exportClientData method so I can provide these override titles in the request, or is there an API from javascript to set field titles?

    #2
    If you're setting the titles on the ListGridFields, you should find that these are already automatically transmitted to the server as part of exportClientData().

    Comment


      #3
      Thanks.

      Can you point me to an example of overriding the exportCLientData method for a data source? I see that the titles are transmitted in the request, but the export ignores those titles and still exports the XLS file with the field names. Is there another request property that I need to set in order to use the "exportOtherFields" titles?

      Comment


        #4
        There isn't an example because an example would not make sense. All aspects of how a request is formed are internal.

        If you think there's an issue where titles are not being respected, try isolating it; this will reveal your usage issue, or a bug.

        There is also a *server-side* API to override the titles - dsRequest.setExportTitles().

        Comment


          #5
          Test case for field title issue

          SmartClient_SNAPSHOT_v90d_2013-05-02


          Test case appears below. I explicitly set the title of the inspections field, the grid shows it, but the XLS does not. Load the page then run this command to export:

          Code:
          gridObject.exportClientData({
          	exportAs : "xls",
          	exportDisplay : "download",
          	exportFilename : "test.xls"
          })
          Code:
          <!DOCTYPE html>
          
          <html>
          <head>
              <title >Chart Test Case</title>
          	
             	<script type="text/javascript" >
          		var isomorphicDir="http://localhost:8080/isomorphic/";
          		
          		var data = [
          			{inspectorID:12345, inspections:206,observations:913,lastInspectionDate:"2012-08-31",index:52.6, inspectionType: {id:123, name:"type1"}},
          			{inspectorID:67890, inspections:66,observations:0,lastInspectionDate:"2013-02-02",index:75.3, inspectionType: {id:123, name:"type1"}},
          			{inspectorID:88776, inspections:66,observations:67,lastInspectionDate:"2013-02-02",index:75.3, inspectionType: {id:123, name:"type1"}},
          			{inspectorID:44556, inspections:206,observations:0,lastInspectionDate:"2012-08-31",index:52.6, inspectionType: {id:123, name:"type1"}}
          		];
          </script>
          	
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Core.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Foundation.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Containers.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Grids.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Forms.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_DataBinding.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Drawing.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_PluginBridges.js"></script> 
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Charts.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Tools.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
          
           <script type="text/javascript">
          
          		
          	</script>
          	
          </head>
          <body>
          
          	<script>
          	
          			var gridObject = isc.ListGrid.create({
          				fields:[
                  {name:"inspectorID", title:"Inspector ID", type:"integer" },
                  {name:"inspections", type:"integer", title:"# Inspections"},
                  {name:"observations", title:"# Observations"}
          			],
          				dataFetchMode : "local",
          				data: data,
          				width : "100%",
          				align : "center",
          				autoFitData : "vertical",
          				autoFitMaxHeight : 400,
          				alternateRecordStyles : true,
          				canAddFormulaFields : true,
          				canAddSummaryFields : true,
          				canGroupBy : true,
          				canReorderFields : true,
          				showGroupSummary : true,
          				groupByMaxRecords : 5
          			});	
          	
          	
          	gridObject.setFieldTitle("inspections", "My New Title");
          	
          	</script>
          	
          
          </body>
          
          </html>
          The request is sending the correct field titles, the export is not respecting it:

          Code:
           "download",
           {
               exportAs:"xls",
               exportFilename:"test.xls",
               exportFields:[
                   "inspectorID",
                   "inspections",
                   "observations"
               ],
               exportOtherFields:{
                   inspectorID:{
                       title:"Inspector ID",
                       fieldNum:0
                   },
                   inspections:{
                       title:"My New Title",
                       fieldNum:1
                   },
                   observations:{
                       title:"# Observations",
                       fieldNum:2
                   }
               }
           }
          Last edited by jwbst21; 2 May 2013, 20:26.

          Comment


            #6
            Please let me know if this is expected behavior or not. We have an upcoming release and I may need to implement a workaround. However, I would rather send the column names in the request as I will not be able to set formula and summary column titles on the server.

            Comment


              #7
              Expected behavior is for the field titles, not field names to show up.
              It looks like we have a (somewhat recent) bug that was preventing this from behaving correctly. We've made a change to address this. Please try the latest nightly build and let us know if you continue to see this behavior

              Thanks
              Isomorphic Software

              Comment


                #8
                Regression with 05/09 nightly

                SmartClient_SNAPSHOT_v90d_2013-05-09

                The nightly build fixed the export field titles - thanks. However, it seems that this build created a regression or another bug.

                If there is a column in the grid that has canExport=false, when the grid is exported an Index out bounds exception is thrown. It seems that the exportOtherFields object is storing the field number from the grid, but this does not exist in the array of fields in exportFields.

                We use these columns for links and other things that we do not want in the export.

                Load the following test case, which contains a field that is not exportable. Then run the following command to export the grid:

                Code:
                gridObject.exportClientData({
                	exportAs : "xls",
                	exportDisplay : "download",
                	exportFilename : "test.xls"
                })
                Test Case:
                Code:
                <!DOCTYPE html>
                
                <html>
                <head>
                    <title >ExportTest Case</title>
                	
                   	<script type="text/javascript" >
                		var isomorphicDir="http://localhost:8080/isomorphic/";
                		
                		var data = [
                			{inspectorID:12345, inspections:206,observations:913,lastInspectionDate:new Date(2012, 8, 13),index:52.6, inspectionType: {id:123, name:"type1"}},
                			{inspectorID:67890, inspections:66,observations:0,lastInspectionDate:new Date(2013, 02,02),index:75.3, inspectionType: {id:123, name:"type1"}},
                			{inspectorID:88776, inspections:66,observations:67,lastInspectionDate:new Date(2013,02,03),index:75.3, inspectionType: {id:123, name:"type1"}},
                			{inspectorID:44556, inspections:206,observations:0,lastInspectionDate:new Date(2012,08,31),index:52.6, inspectionType: {id:123, name:"type1"}}
                		];
                </script>
                	
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Core.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Foundation.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Containers.js"></script>
                  <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Grids.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Forms.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_DataBinding.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Drawing.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_PluginBridges.js"></script> 
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Charts.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/development/ISC_Tools.js"></script>
                 <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
                	
                </head>
                <body>
                
                	<br><br>
                	<script>
                	
                			var gridObject = isc.ListGrid.create({
                				fields:[
                					{name:"inspectorID", title:"Inspector ID", type:"integer" },
                					{name:"inspections", type:"integer", title:"# Inspections"},
                					{name:"static", type:"string", canExport:false, title:"Static Field"},
                					{name:"observations", title:"# Observations"}
                		
                				],
                				dataFetchMode : "local",
                				data: data,
                				width : "100%",
                				align : "center",
                				autoFitData : "vertical",
                				autoFitMaxHeight : 400,
                				alternateRecordStyles : true,
                				canAddFormulaFields : true,
                				canAddSummaryFields : true,
                				canGroupBy : true,
                				canReorderFields : true,
                				showGroupSummary : true,
                				groupByMaxRecords : 5
                			});	
                
                	
                	</script>
                	<br><br>
                
                </body>
                
                </html>
                Request:
                Code:
                === 2013-05-09 17:10:56,431 [or10] DEBUG RPCManager - Request #1 (RPCRequest) data: {
                    appID:"isc_builtin",
                    className:"builtin",
                    methodName:"downloadClientExport",
                    arguments:[
                        [
                            {
                                inspectorID:"12345",
                                inspections:"206",
                                observations:"913"
                            },
                            {
                                inspectorID:"67890",
                                inspections:"66",
                                observations:"0"
                            },
                            {
                                inspectorID:"88776",
                                inspections:"66",
                                observations:"67"
                            },
                            {
                                inspectorID:"44556",
                                inspections:"206",
                                observations:"0"
                            }
                        ],
                        "xls",
                        "test.xls",
                        "download",
                        {
                            exportAs:"xls",
                            exportFilename:"test.xls",
                            exportFields:[
                                "inspectorID",
                                "inspections",
                                "observations"
                            ],
                            exportOtherFields:{
                                inspectorID:{
                                    title:"Inspector ID",
                                    fieldNum:0
                                },
                                inspections:{
                                    title:"# Inspections",
                                    fieldNum:1
                                },
                                observations:{
                                    title:"# Observations",
                                    fieldNum:3
                                }
                            }
                        }
                    ],
                    is_ISC_RPC_DMI:true
                }
                Exception:
                Code:
                === 2013-05-09 17:11:43,859 [sor6] INFO  BuiltinRPC - Generating and streaming xls file...
                java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
                        at java.util.ArrayList.RangeCheck(ArrayList.java:546)
                        at java.util.ArrayList.set(ArrayList.java:337)
                        at com.isomorphic.rpc.ExcelDataExport.calcOtherFields(ExcelDataExport.java:712)
                        at com.isomorphic.rpc.ExcelDataExport.getExportObject(ExcelDataExport.java:219)
                        at com.isomorphic.rpc.DataExport.exportResultSet(DataExport.java:607)
                        at com.isomorphic.rpc.DataExport.exportResultSet(DataExport.java:457)
                        at com.isomorphic.rpc.BuiltinRPC.downloadClientExport(BuiltinRPC.java:764)
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                        at java.lang.reflect.Method.invoke(Method.java:592)
                        at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:972)
                        at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:804)
                        at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:309)
                        at com.isomorphic.rpc.RPCDMI.execute(RPCDMI.java:66)
                        at com.isomorphic.rpc.RPCRequest.execute(RPCRequest.java:231)
                        at com.isomorphic.servlet.IDACall.handleRPCRequest(IDACall.java:284)
                        at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:168)
                        at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:137)
                        at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
                        at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
                        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                        at com.isomorphic.js.JSSyntaxScannerFilter.doFilter(JSSyntaxScannerFilter.java:241)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                        at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
                        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
                        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
                        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
                        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
                        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
                        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
                        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
                        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
                        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
                        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
                        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
                        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)

                Comment


                  #9
                  Sorry for the inconvenience, and thanks for letting us know.
                  We've made another change to address this. Please try the next nightly build (May 10)

                  Regards
                  Isomorphic Software

                  Comment


                    #10
                    Regression with 5/10 build

                    Same test case and version (5/10). Now formula and summary columns are not being exported.

                    Repro steps:
                    - Load test case
                    - Create a formula field
                    - Create a summary field
                    - Export the grid to XLS with the command:
                    Code:
                    gridObject.exportClientData({
                    	exportAs : "xls",
                    	exportDisplay : "download",
                    	exportFilename : "test.xls"
                    })
                    The formula and summary fields do not appear in the request either:
                    Code:
                     "xls",
                     "test.xls",
                     "download",
                     {
                         exportAs:"xls",
                         exportFilename:"test.xls",
                         exportFields:[
                             "inspectorID",
                             "inspections",
                             "observations",
                             "lastInspectionDate",
                             "isLocal",
                             "segment"
                         ],
                         formulaFields:[
                             {
                                 text:"B",
                                 formulaVars:{
                                     B:"inspections"
                                 },
                                 name:"formulaField1",
                                 title:"New Field"
                             }
                         ],
                         formulaRemap:[
                             {
                                 name:"inspectorID",
                                 title:"Inspector ID"
                             },
                             {
                                 name:"inspections",
                                 title:"# Inspections"
                             },
                             {
                                 name:"static",
                                 title:"Static Field"
                             },
                             {
                                 name:"observations",
                                 title:"# Observations"
                             },
                             {
                                 name:"lastInspectionDate",
                                 title:"Last Inspection"
                             },
                             {
                                 name:"isLocal",
                                 title:"Local"
                             },
                             {
                                 name:"segment",
                                 title:"Segment"
                             },
                             {
                                 name:"formulaField1",
                                 title:"New Field"
                             },
                             {
                                 name:"summaryField1",
                                 title:"New Field"
                             }
                         ],
                         exportOtherFields:{
                             inspectorID:"Inspector ID",
                             inspections:"# Inspections",
                             observations:"# Observations",
                             lastInspectionDate:"Last Inspection",
                             isLocal:"Local",
                             segment:"Segment"
                    }

                    Comment


                      #11
                      Fixed for tomorrow's 3.1 and 4.0 builds, thanks for pointing out the regression.

                      Comment

                      Working...
                      X