Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hell sir,
i am using knockoutjs
and i have observablearray with multiple duplicate rows

purchaseitems(observablearray with items)
-------
vat prevat vateamount
--- ------- -----------
5______15_______ 20
10____ 20_______ 300
5 ____ 25 _______ 200
10 ____28 _______ 210


i want to get and display like
vat prevat vateamount
--- ------- -----------
5______30_______ 220
10____ 48_______ 510

use vat as a key that if multipletimes vat is occured then sum of prevat and vateamount
.....
i dont know how to do...
please help
thank you in advance
have a nice sunday
Posted
Comments
Kornfeld Eliyahu Peter 8-Feb-15 5:31am    
You probably have to create a new observable object (array) with computed fields...
Check this: http://knockoutjs.com/documentation/computedObservables.html

1 solution

As stated above you should create a computed variable which returns your summed array and bind to that.
To do the summary itself you could consider adding underscore.js to the mix. This library provides many usefull function do deal with arrays.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900