Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9117419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:53:33+00:00 2026-06-17T04:53:33+00:00

I have managed to find examples online of single calculated items, but does anybody

  • 0

I have managed to find examples online of single calculated items, but does anybody have an example of a simple knockout grid with a field that is calculated based upon the value of other fields?

EDIT : Here is some code that I have written, but I am pretty sure I am going about it the wrong way so far :

    <script type="text/javascript" src="@Url.Content("~/Scripts/knockout-2.1.0.js")"></script>
<script type="text/javascript">

    function QBRatingsViewModel() {
            var self = this;
            var baseUri = '@ViewBag.ApiUrl';
            self.qbratings = ko.observableArray();
            this.Interception = ko.observable();
            this.Gain = ko.observable();

            this.CalculatedRating = ko.computed(function() {        
                return this.Interception() * this.Gain();
            }, this);

            $.getJSON("/api/qbrating", self.qbratings);
    }

    $(document).ready(function () {
        ko.applyBindings(new QBRatingsViewModel());
    }); 

  </script>


<div style="padding-left: 10px;">
    <div id="divQBRatings" style="padding-left: 3px; width: 750px;">
        <table class="grid" cellspacing="0" cellpadding="0" id="QBRatingsGrid">
            <tr class="gridheader"><td style="width: 30px;">Id</td><td width="10" /><td style="width: 40px;">Season</td><td width="10" /><td style="width: 70px;">Team </td><td width="10" /><td style="width: 130px;">Completion </td><td width="10" /><td style="width: 190px;">Gain </td><td width="10" /><td style="width: 30px;">Touchdown </td><td width="10" /><td style="width: 30px;">Interception </td><td width="10" /><td style="width: 30px;">Rating</td><td width="10" /><td></td></tr>
            <tbody data-bind="foreach: qbratings" class="grid">
                <tr>
                    <td><span style="width: 30px;" data-bind="text: $data.Id"></span></td>
                    <td width="10" />
                    <td><span style="width: 40px;" data-bind="text: $data.Season"></span></td>
                    <td width="10" />
                    <td><span style="width: 130px;"data-bind="text: $data.TeamName"></span></td>
                    <td width="10" />
                    <td><span style="width: 190px;" data-bind="text: $data.Completion"></span></td>
                    <td width="10" />
                    <td><span style="width: 190px;" data-bind="text: $data.Gain"></span></td>
                    <td width="10" />
                    <td><span style="width: 190px;" data-bind="text: $data.Touchdown"></span></td>
                    <td width="10" />
                    <td><span style="width: 190px;" data-bind="text: $data.Interception"></span></td>
                    <td width="10" />
                    <td><span style="width: 190px;" data-bind="text: $data.CalculatedRating"></span></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:53:34+00:00Added an answer on June 17, 2026 at 4:53 am

    I don’t know if your calculated property is related to item or whole view model. If it’s related to item you should do something like this:

    $.getJSON("/api/qbrating", function (result) {
        ko.utils.arrayForEach(result, function (item) {
            item.CalculatedRating = item.Interception * item.Gain;
        });
        self.qbratings(result);
    });
    

    If it’s related to whole model you should use $parent instead of $data:

    <td><span style="width: 190px;" data-bind="text: $parent.CalculatedRating"></span></td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can find many examples on how to do this in managed c++ but
Is it possible to perform a global reversed-find on NHibernate-managed objects? Specifically, I have
I have managed to run hadoop examples grep, wordcount... however I am finding some
I have 3 levels of data to manage in Knockout, but only the first
Does anyone know where can I find a tutorial or example on how to
I have a simple question that I assume does not have a simple solution.
I have a basic sound manager class that's derived from an online example: http://www.xnawiki.com/index.php?title=Basic_Sound_Manager_For_XNA_GS_3.0
I have been trying to look online for any solutions or examples on how
I have managed to extract the filename and the extension and passed that to
I have managed to confuse myself whether I should return E_NOTIMPL or E_NOINTERFACE from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.