PDA

View Full Version : Apply grid summary rendering/styling to the last row in a grid



qt4x11
17 Jan 2012, 3:51 PM
I have a grid panel populated via a store with an ajax proxy/reader that reads json data provided by a remote java servlet. I was going to set up a summary row at the bottom of my grid with totals and averages for various columns in my grid using the Summary api, but I realized that my java servlet already provides summary and totals information as the last JSON object in the JSON array that it generates. This JSON object is distinguishable in that, it does not have a value for 'stationDescriptor'. You can see this summary row as the last object in the JSON array here



[{"avgInteractionTimeWait":310.4482275862069,"stationDescriptor":"Web Request","numberOfRequestsNoWait":364,"avgWaitTimeNoWaitString":"0:05","avgWaitTimeWaitString":"9:04","stationID":0,"numberOfRequestsNoWaitForResponseTime":358,"pctNumberOfRequestsWait":"46.49%","pctNumberOfRequestsLost":"7.79%","numberOfRequests":1310,"avgInteractionTime":"13:14","avgInteractionTimeWaitString":"5:10","avgInteractionTimeNoWaitString":"26:42","pctNumberOfRequestsNoWait":"27.79%","pctNumberOfRequestsNotStaffed":"17.94%","numberOfRequestsWait":609,"numberOfRequestsLost":102,"numberOfRequestsNotStaffed":235,"avgInteractionTimeNoWait":1602.4697648351648},{"avgInteractionTimeWait":1017,"stationDescriptor":" - Chicago / Jamie Dev","numberOfRequestsNoWait":26,"avgWaitTimeNoWaitString":"0:02","avgWaitTimeWaitString":"0:03","stationID":10,"numberOfRequestsNoWaitForResponseTime":26,"pctNumberOfRequestsWait":"3.57%","pctNumberOfRequestsLost":"0%","numberOfRequests":28,"avgInteractionTime":"8:40","avgInteractionTimeWaitString":"16:57","avgInteractionTimeNoWaitString":"8:21","pctNumberOfRequestsNoWait":"92.86%","pctNumberOfRequestsNotStaffed":"3.57%","numberOfRequestsWait":1,"numberOfRequestsLost":0,"numberOfRequestsNotStaffed":1,"avgInteractionTimeNoWait":501.1923},{"avgInteractionTimeWait":17.8333,"stationDescriptor":" - Chicago / CyberNet All in One","numberOfRequestsNoWait":22,"avgWaitTimeNoWaitString":"0:05","avgWaitTimeWaitString":"0:04","stationID":15,"numberOfRequestsNoWaitForResponseTime":22,"pctNumberOfRequestsWait":"10.53%","pctNumberOfRequestsLost":"35.09%","numberOfRequests":57,"avgInteractionTime":"4:05","avgInteractionTimeWaitString":"0:18","avgInteractionTimeNoWaitString":"5:07","pctNumberOfRequestsNoWait":"38.6%","pctNumberOfRequestsNotStaffed":"15.79%","numberOfRequestsWait":6,"numberOfRequestsLost":20,"numberOfRequestsNotStaffed":9,"avgInteractionTimeNoWait":306.6364},{"avgInteractionTimeWait":0,"stationDescriptor":" - Amazon / Hertz VCSR 1.5 Test Unit","numberOfRequestsNoWait":2,"avgWaitTimeNoWaitString":"0:02","avgWaitTimeWaitString":"0:02","stationID":22,"numberOfRequestsNoWaitForResponseTime":2,"pctNumberOfRequestsWait":"0%","pctNumberOfRequestsLost":"66.67%","numberOfRequests":6,"avgInteractionTime":"1:37","avgInteractionTimeWaitString":"0:00","avgInteractionTimeNoWaitString":"1:37","pctNumberOfRequestsNoWait":"33.33%","pctNumberOfRequestsNotStaffed":"0%","numberOfRequestsWait":0,"numberOfRequestsLost":4,"numberOfRequestsNotStaffed":0,"avgInteractionTimeNoWait":97},{"avgInteractionTimeWait":736,"stationDescriptor":"Accenture Healthcare / Accenture Healthcare","numberOfRequestsNoWait":3,"avgWaitTimeNoWaitString":"0:04","avgWaitTimeWaitString":"0:14","stationID":40,"numberOfRequestsNoWaitForResponseTime":3,"pctNumberOfRequestsWait":"11.11%","pctNumberOfRequestsLost":"0%","numberOfRequests":9,"avgInteractionTime":"10:16","avgInteractionTimeWaitString":"12:16","avgInteractionTimeNoWaitString":"9:36","pctNumberOfRequestsNoWait":"33.33%","pctNumberOfRequestsNotStaffed":"55.56%","numberOfRequestsWait":1,"numberOfRequestsLost":0,"numberOfRequestsNotStaffed":5,"avgInteractionTimeNoWait":575.6667},{"avgInteractionTimeWait":309.43755332252834,"stationDescriptor":"","numberOfRequestsNoWait":417,"avgWaitTimeNoWaitString":"0:05","avgWaitTimeWaitString":"8:32","numberOfRequestsNoWaitForResponseTime":411,"pctNumberOfRequestsWait":"43.76%","pctNumberOfRequestsLost":"8.94%","numberOfRequests":1410,"avgInteractionTime":"12:50","avgInteractionTimeWaitString":"5:09","avgInteractionTimeNoWaitString":"24:11","pctNumberOfRequestsNoWait":"29.57%","pctNumberOfRequestsNotStaffed":"17.73%","numberOfRequestsWait":617,"numberOfRequestsLost":126,"numberOfRequestsNotStaffed":250,"avgInteractionTimeNoWait":1450.8321225419663}]


Is there a way I can pull this 'summary' object out of my JSON array and have my Grid render it using a summaryRenderer? This seems like it would take less work than modifying my servlet not to include this summary information as part of the JSON array that it returns, and then setting up summary reporting on a per column basis using the Summary api, as this work has already been done server side. Thanks for any suggestions.

mitchellsimoens
18 Jan 2012, 6:13 AM
You can extend Ext.grid.feature.Summary and override the generateSummaryData method.

qt4x11
18 Jan 2012, 6:44 AM
That seems rather involved to me right now. Is it easy to extend the api? I know how to do this in java but have never done this type of thing in js. Is there any examples or threads you can point me to that would get me started extending api classes? I was also thinking - can I make use of Ext.data.Store filtering to do this? I was looking through the api and it seemed that approach may have some potential. Thanks again.

mitchellsimoens
18 Jan 2012, 6:55 AM
The framework is full of extending with the use of Ext.define... every class is an extension of another.