this is my itemModel:
var itemModel = function (id,description,picture,totalInventory,retailPrice,dealerPrice,category,brand,unitOfMeasure,createdBy,status,highestCost, lowestCost) {
var self = this;
self.ID = ko.observable(id);
self.Description = ko.observable(description);
self.Picture = ko.observable(picture);
self.TotalInventory = ko.observable(totalInventory);
self.RetailPrice = ko.observable(retailPrice);
self.DealerPrice = ko.observable(dealerPrice);
self.Category = ko.observable(category);
self.Brand = ko.observable(brand);
self.UnitOfMeasure = ko.observable(unitOfMeasure);
self.CreatedBy = ko.observable(createdBy);
self.Status = ko.observable(status);
self.HighestCost = ko.observable(highestCost);
self.LowestCost = ko.observable(lowestCost);};
I have this method to get the items
self.GetItems = function(){
$.getJSON("/Items/GetItems",{status: self.ItemStatus()}, function (result) {
for (var i = 0, j = result.data.length; i < j; i++){
item = result.data[i];
underlyingArray.push(new itemModel(
item.ID,
item.Description,
item.Picture,
....computetotalinventoryhere...,
item.RetailPrice,
item.DelearPrice,
item.Category,
item.Brand,
item.UnitOfMeasure,
item.CreatedBy,
item.Status,
item.HighestCost,
item.LowestCost
));
}
self.list.valueHasMutated();
}
};
I want to create a function to compute the total inventory. Is that possible in knockout? or any suggestion on how to do this. thanks.