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 8061845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:28:42+00:00 2026-06-05T10:28:42+00:00

So I have two separate models, one ‘items’ model, the second a ‘sites’ model…

  • 0

So I have two separate models, one ‘items’ model, the second a ‘sites’
model… I’m using KO to bind this data to two separate elements on
the DOM (and working as needed), but I’ve found a need to replace one
of my bound columns on one of my models, with data from the other.

On my ‘items’ model, I have a site ID column, that I’d love to swap
with the actual ‘SiteName’ property on that model (simple name, value-
pair – SiteName, SiteId)… Does any one know a way to do this within
KO?

I really want to keep the model data itself in tact on the server side,
verses just creating a custom model on the server side that does it for me.

I’m sure I could give those elements a special class, and loop
through them and replace them manually with jQuery, but I thought that
KO might have an easier way of doing this.

Thanks!

I have tried something like this, but it doesn’t seem to work (yes, I know div tags within a table element are not standards based, I just wanted to see if it would work, and if it did, I’d transition from the table to another formatting option)

<tbody data-bind="foreach: items">
        <tr data-bind="click: updateItem">
            <td data-bind="text: ItemName"></td>
            <div data-bind="foreach: sites">
                <div data-bind="if: items.SiteId = sites.SiteId">
                    <td data-bind="text: sites.SiteName"></td>
                </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-05T10:28:43+00:00Added an answer on June 5, 2026 at 10:28 am

    The jQuery to do this using my returned model is:

    $(function () {
                $('#allItems tr .siteIdCell').each(function () {
                    for (i in allSites) {
                        if (allSites[i].SiteId == $(this).html()) {
                            $(this).html(allSites[i].SiteName);
                        }
                    }
                });
            });
    

    Where .siteIdCell is the class I applied to the columns using this value, and allSites is the object array I’m receiving via JSON.

    Not sure if I’ll get many responses, but I just figured I’d update this if anyone else has the same issue, and there’s no ability to do this in KO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DUPLICATE: Using a Django custom model method property in order_by() I have two models;
I have two models in separate apps: # Groups app class Group(models.Model): name =
I have two related validations on separate models. I can validate one way but
I have a form that calls on two separate models. My validation works correctly
I have two separate sets of tables in the same database that model the
I have two separate caches running in a JVM (one controlled by a third
We have two databases, in two separate locations. One of the databases resides in
I'm using Django 1.2 and I want to have two user types (one for
Say I have two tables (I am using Django, but this question is mostly
I'm using Ruby 1.8.7 and Rails 2.3.8 I have two ActiveRecord Models, A and

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.