PDA

View Full Version : grid automatic computation



mond
17 Mar 2011, 5:56 PM
Hi it is possible in the grid component to do some math operations automatically?
like
assuming that ratings are based on user inputs.


--------------------------------------------
Items | Ratings | Weights | Score |
--------------------------------------------
Item A | 4.5 (x)| 80% = ____|
--------------------------------------------
Item B | 3 (x)| 20% = ____|
--------------------------------------------
Total Score = ______


can you give some idea about the computations in grid.
help please.

jratcliff
17 Mar 2011, 6:11 PM
In your ColumnModel define a custom renderer for the column(s) that you want to have custom calculations done.

Just take a look at the source code of the Array Grid example to get an idea of how to do custom column renders:

http://dev.sencha.com/deploy/dev/examples/grid/array-grid.html

mond
17 Mar 2011, 7:06 PM
but how do I compute the total score?



var item = 0;
var tempdata = [];
var rec;
var g = Ext.getCmp('itemlist');
while (g.store.getAt(item)) {
rec = g.store.getAt(item);
tempdata.push(
new Array(
rec.data['score']
))
item++;
}

tempdata + tempdata; ??