开发者

extjs problem calculation of rows

i have a table

开发者_如何学JAVA Fields class 1 class 2 class 3 class 4

a1       10        240       340       401

a2       12        270       340       405      

a3       12        270       340       405      

a4       15        270       360       405      

a5       17        720       530       450      

i have this in grid as well as in Json.store , what i have to do is perform mathematical calculation each time the grid is refreshed by "table name".reconfigure(..... , ....)

consider the column "class1" , value(a5) = ( value(a1)+ 2*value(a2) + 3*value(a3) ) /value(a4) can anybody please help he on this problem ,

I will be very very Thankful for help :)


As I'm not sure what aspect of the problem you are having difficulty with, I'll address both at a high level. Generally speaking you want to have your reconfigure method update the Ext Store, which will then trigger an event that the Grid should handle. Basically, change the Store and your Grid will be updated automatically.

As far as generating the correct new row... it seems fairly straightforward - a rough pass:

/*for each field foo_X through foo_N:*/
var lastElementIndex = store.data.size-1; 
var total = 0;
for (var i=0; i<; i++) {
    if (i != lastElementIndex) {
        total += store.data[i].get(foo_X)*i;
    } else {
        total = total/store.data[i].get(foo_x);
    }

}
/*construct your json object with the field foo*/
/*after looping through all your fields, create your record and add it to the Store*/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜