简体   繁体   中英

Extjs 4.2: get value from the grid

So let's say I have this grid

id time

1 10

2 5

3 10

etc..

How do I get the sum of the values under 'time'?

EDIT

I tried to get the array of the value from the grid with this code

var sel2 = scope.getPlaylistDetailsGrid().data.items;

But it says: Uncaught TypeError: Cannot read property 'items' of undefined

If you want to display the sum in the grid, then Riku's suggestion of the summary row is perfect. If you need to just get a sum in code, you can check out the store's sum() method: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-sum

Riku's suggestion:

在此输入图像描述

I think it would be usefull for others if i point it out as an answer.

You could use summary row, to achieve this behaviour. Here is example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM