Announcement

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

    RecordSummaryFunction being called for grid summary but not group summaries

    It appears that my custom RecordSummaryFunction is being called for every regular row ListGrid and for the grid summary row but not for the group summary rows. Also, when it is called for the grid summary row the other values in the record with which I am calculating the summary value have the value "&nbsp".

    I was hoping that my custom RecordSummaryFunction would be called for both grid and group summary rows and that the other fields in the record would have their standard summary function values already calculated (the ones I'm using in my custom summary function all have standard RecordSummaryFunctionType.SUM.

    The javadocs for RecordSummaryFunction make no mention of what to expect for grid or group summary records. Can you clarify?

    #2
    Any guidance on RecordSummaryFunction? I need to calculate the value for a number of columns based on the value of other columns in the same record. Is this the right technique to use? Sure seems like it. It works on normal grid rows and on group summary rows, but not on the grid summary row. Here is the code ...
    Code:
    field.setRecordSummaryFunction(new RecordSummaryFunction() {
    	@Override
    	public Object getSummaryValue(Record record,
    			ListGridField[] fields, ListGridField summaryField) {
    		return getCalculatedValue(summaryField.getName(), record).toString();
    	}
    });
    protected Float getCalculatedValue(String fieldName, Record record) {
    	Float salesSTD = record.getAttributeAsFloat("UnitSalesSTD");
    	Float salesTW = record.getAttributeAsFloat("UnitSalesTW");
    	Float salesLW = record.getAttributeAsFloat("UnitSalesLW");
    	Float inventory = record.getAttributeAsFloat("UnitInventory");
    	Float replenMax = record.getAttributeAsFloat("ReplenMax");
    	if ("sellOffSTD".equals(fieldName) && salesSTD+inventory!=0)
    		return salesSTD / (salesSTD + inventory);
    	else if ("sellOffTW".equals(fieldName) && salesTW+inventory!=0)
    		return salesTW / (salesTW + inventory);	
    	else if ("salesStock".equals(fieldName) && inventory!=0)
    		return (salesTW+salesLW) / inventory;
    	else if ("weeksSupply".equals(fieldName) && salesLW!=0)
    		return inventory / salesLW;
    	else if ("replenMaxNeed".equals(fieldName))
    		return (inventory>replenMax) ? 0 : replenMax - inventory;
    	else return new Float(0);
    }
    When the RecordSummaryFunction is invoked on the grid summary row it gets the following errors.
    Code:
    10:31:39.273 [ERROR] [ipgui] Uncaught exception escaped
    com.google.gwt.dev.shell.HostedModeException: invoke arguments: JS value of type JavaScript object(22897), expected float
        at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:118)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:65)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
        at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1713)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.util.JSOHelper.getAttributeAsFloat(JSOHelper.java)
        at com.smartgwt.client.core.DataClass.getAttributeAsFloat(DataClass.java:161)
        at com.islandpacific.gui.client.ItemStoreDetails.getCalculatedValue(ItemStoreDetails.java:190)
        at com.islandpacific.gui.client.ItemStoreDetails$2.getSummaryValue(ItemStoreDetails.java:143)
        at sun.reflect.GeneratedMethodAccessor176.invoke(Unknown Source)
       ...
       ...

    Comment


      #3
      Unable to reproduce against SVN. I take it you're using a pretty recent nightly, right? Can you provide the following info :

      1) Smart GWT version
      2) OS
      3) Hosted mode browser and have you tried different browser types?

      I modified the Grid Summary sample as follows and it works fine.

      Code:
      ListGridSummaryField totalField = new ListGridSummaryField("total", "Total");
      totalField.setAlign(Alignment.RIGHT);        
      //original code
      //totalField.setRecordSummaryFunction(RecordSummaryFunctionType.MULTIPLIER);
      
      //new code
      totalField.setRecordSummaryFunction(new RecordSummaryFunction() {
          @Override
          public Object getSummaryValue(Record record, ListGridField[] fields, ListGridField summaryField) {
              return new Float(5);
          }
      });
      Please modify this sample so that the issue is reproducible or provide a standalone testcase of your own.

      Sanjiv

      Comment


        #4
        I'm using the 2.1 release SC_SNAPSHOT-2010-03-09/EVAL Deployment, not a recent nightly. Mac OSX 10.6.3 with Firefox and Safari.

        The issue is not that the RecordSummaryFunction is not being called (I was confused about that at first). The problem is that the other fields in the record are not accessible when the summary function is called on the grid summary row. So, for example, this line in the summary function ...

        Float salesSTD = record.getAttributeAsFloat("UnitSalesSTD");

        ... works fine, except on the grid total row. In that case it gets this error.

        com.google.gwt.dev.shell.HostedModeException: invoke arguments: JS value of type JavaScript object(13597), expected float
        at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:118)

        Comment


          #5
          I'm still not able to reproduce this. Can you modify the Grid Summaries showcase sample to demonstrate the issue?

          Sanjiv

          Comment


            #6
            Where can I download the SmartGWT showcase project. The smartgwt-ee distribution only has the ShowcaseEE sample project which does not include the grid summary sample.

            Comment


              #7
              Simply go to the Grid Summary sample and then click the View Source button in the toolbar. You should see the standalone source for the sample which you can copy-paste locally. I see that the View Source tab for this sample is missing the source of the OrderItemLocalDS class. You can find this in the SmartGWT LGPL distribution or view it directly from SVN here.

              Sanjiv

              Comment


                #8
                I got the Grid Summary sample working locally and made exactly the same change as you and I receive this error for every grid row, not just the grid summary row. It looks like it is a problem in the 2.1 release that has been fixed? How do I get the latest 2.1 EE build. Preferably not the eval version.
                Code:
                17:41:06.521 [ERROR] [showcase] Uncaught exception escaped
                com.google.gwt.core.client.JavaScriptException: (null): null
                    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
                    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
                    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
                    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
                    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
                    at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source)
                    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                    at java.lang.reflect.Method.invoke(Method.java:597)
                    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
                    at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
                    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
                    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
                    at java.lang.Thread.run(Thread.java:637)

                Comment


                  #9
                  Yes, its quite possible this was fixed post 2.1. The nightly builds are here. Would be good if you could quickly confirm that the issue has been fixed.
                  Last edited by sjivan; 2 May 2010, 16:37.

                  Comment


                    #10
                    I tried the latest nightly from May 2nd, but after installing it I get an error dialog with "java.lang.AssertionError: Use setWidth("*") rather than setWidth("100%"): null[Ljava.lang.StackTraceElement;@113e112". The app won't run at all, although I do see from the console that a lot of the DSRequests to the server are working.

                    I'll try a less "cutting edge" build and let you know if I find one that works and does not have the original problem.

                    Comment


                      #11
                      You should really just update your code to do what the assert message says. ie call formItem.setWidth("*") instead of formItem.setWidth("100%") as formItems do now support percent sizing.

                      Sanjiv

                      Comment


                        #12
                        Thank you. The nightly from May 2nd does indeed fix the grid summary problem, but there appears to be some regression with $defaultWhereClause. In every instance I've looked at so far, no WHERE clause is being generated. Has there been a deliberate change in that area where a code change is needed on my part? This code was working prior to installing the latest nightly.

                        My ds.xml includes WHERE $defaultWhereClause. The DSRequest looks like this ...
                        Code:
                        {
                            "actionURL":"http://localhost:8888/ipgui/sc/IDACall", 
                            "showPrompt":true, 
                            "prompt":"Finding Records that match your criteria...", 
                            "transport":"xmlHttpRequest", 
                            "promptStyle":"dialog", 
                            "params":{
                                "GroupLevel":"style"
                            }, 
                            "bypassCache":true, 
                            "data":{
                                "criteria":{
                                    "operator":"and", 
                                    "criteria":[
                                        {
                                            "fieldName":"ICLS", 
                                            "operator":"equals", 
                                            "value":"122"
                                        }
                                    ]
                                }, 
                                "operationConfig":{
                                    "dataSource":"IPItemMasterDS", 
                                    "repo":null, 
                                    "operationType":"fetch", 
                                    "textMatchStyle":"exact"
                                }, 
                                "startRow":0, 
                                "endRow":75, 
                                "sortBy":[
                                    "ICLS", 
                                    "IVEN", 
                                    "ISTY", 
                                    "ICLR", 
                                    "ISIZ"
                                ], 
                                "componentId":"isc_MerchNavigator$1_0", 
                                "appID":"builtinApplication", 
                                "operation":"IPItemMasterDS_fetch", 
                                "oldValues":{
                                    "operator":"and", 
                                    "criteria":[
                                        {
                                            "fieldName":"ICLS", 
                                            "operator":"equals", 
                                            "value":"122"
                                        }
                                    ]
                                }
                            }
                        }
                        But the generated WHERE clause looks like this ...
                        Code:
                        WHERE ('1'='1')
                        Last edited by jay.l.fisher; 3 May 2010, 04:52.

                        Comment

                        Working...
                        X