Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #11  
Old 19th Mar 2012, 14:23
senordhuff
Guest
 
Posts: n/a
Default

I cannot get this to work the way I want after much trial and error. I want the grid summary and the group summary to be handled the exact same way.

I am happy with the way the grid summary is formatted. It is showing blank. But, it seems like the group summary is controlled by formatCellValue. I tried using formatGroupSummary like you see in the code below. But, it isn't having any effect. So, how can I have a summary function on the Unit Price column in this example that returns a blank instead of an NA for the group summary? Am I doing something wrong in the way I'm trying to use formatGroupSummary? To me, it seems like the group summary is tied to formatCellValue whereas the grid summary is not.

I hope you understand I have simplified my example from our production application to provide you a simple test case. We want to define a summary function for every column. But, we want the summary function to show a blank value even if formatCellValue shows an NA for the individual cells. And, we want it to work consistently between the group summaries and the grid summaries.

Code:
isc.ListGrid.create({
    ID: "companyList",
    width:600, height:520,
    alternateRecordStyles:true,
    autoFetchData:true,
    dataSource:orderItemLocalDS,
    showAllRecords:true,
    groupByField:"category", groupStartOpen:"all",
    canEdit:true, editEvent:"click",
    
    showGridSummary:true,
    showGroupSummary:true,
    fields:[
        {name:"orderID", includeInRecordSummary:false, summaryFunction:"count"},
        {name:"itemDescription"},
        {name:"category", showGridSummary:true, 
            getGridSummary:function (records, summaryField) {
                var seenCategories = {};
                for (var i = 0; i < records.length; i++) {
                    seenCategories[records[i].category] = true;
                }
                var totalCategories = isc.getKeys(seenCategories).length;
                return totalCategories + " Categories";
                
            }
        },
        {name:"shipDate", showGroupSummary:true, showGridSummary:false, summaryFunction:"max"},
        
        {name:"quantity", showGroupSummary:false, showGridSummary:false},
        {name:"unitPrice", showGroupSummary:true, showGridSummary:true,
         formatCellValue:function (value) {
             if (isc.isA.Number(value)) {
                return value.toCurrencyString("$");
             }
             return "NA";
         },
         formatGroupSummary:function (value) {
             if (isc.isA.Number(value)) {
                return value.toCurrencyString("$");
             }
             return null;
         },
        summaryFunction:"return null"
        },
        {name:"Total", type:"summary", recordSummaryFunction:"multiplier",
         summaryFunction:"sum",
         showGridSummary:true, showGroupSummary:true,
         align:"right",
         formatCellValue:function (value) {
             if (isc.isA.Number(value)) {
                return value.toCurrencyString("$");
             }
             return value;
         }
        }
    ]
})
Reply With Quote
  #12  
Old 21st Mar 2012, 10:10
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,600
Default

We see the discrepancy. The issue is basically that when a group-summary row has a calculated value of 'null', it applies the invalidSummaryValue to the cell, but then runs the standard 'formatCellValue()' method on top of that, whereas when a grid summary has a calculated value of null it does not run through formatCellValue(). Clearly the behavior should be the same in both cases. We're looking at how best to resolve this in the code.

However for now the easiest way to get things running will be to modify your formatter to handle being passed a group, or grid summary row:
Code:
        {name:"unitPrice", showGroupSummary:true, showGridSummary:true,
         formatCellValue:function (value, record, rowNum, colNum, grid) {
             if (isc.isA.Number(value)) {
                return value.toCurrencyString("$");
             }
             if (record.isGroupSummary || record.isGridSummary) return "&nbsp;";
             return "NA";
         },
        summaryFunction:"return null"
        },
Reply With Quote
  #13  
Old 22nd Mar 2012, 02:21
senordhuff
Guest
 
Posts: n/a
Default

Thank you. That tweak will work for now.
Reply With Quote
  #14  
Old 22nd Mar 2012, 09:45
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 30,600
Default

A quick update to let you know that we've resolved these discrepancies in the 8.3d branch.
However the change we made to get this working, while not drastic, is moderately involved and given that the solution suggested here should work for you we don't plan to immediately port across to 8.2p.

If this is going to prove unacceptable (for example you find you can't get the behavior you need out of 8.2 after all), let us know and we'll update 8.2
Reply With Quote
  #15  
Old 22nd Mar 2012, 09:51
senordhuff
Guest
 
Posts: n/a
Default

Thanks for the update. I believe the workaround is sufficient for me so no need to port to 8.2.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListGrid Group summary and Grid Summary ara071286 Smart GWT Technical Q&A 10 27th Mar 2013 09:40
ListGrid header created when showing group summary in header ignores grid size mlyles Smart GWT Technical Q&A 0 13th Oct 2011 13:58
Group summary update on select tahvero_ Smart GWT Technical Q&A 7 12th Nov 2010 07:31
Formula fields show in group summary but not grid summary jay.l.fisher Smart GWT Technical Q&A 1 14th May 2010 07:36
RecordSummaryFunction being called for grid summary but not group summaries jay.l.fisher Smart GWT Technical Q&A 11 3rd May 2010 04:46

© 2010,2011 Isomorphic Software. All Rights Reserved