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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:45:29+00:00 2026-06-09T08:45:29+00:00

How can I create the following calendar grid using knockout binding?: There will be

  • 0

How can I create the following calendar grid using knockout binding?:
enter image description here

There will be 7 columns. (one for each day). The first row (header) of the table will contain the day and date. The 2nd row will contain the values for the respective date. The next row will be another header, again followed by values. Repeat until end of the month.

I have all my data in an observable collection object:

function CalendarDate(id, date, volume) {
    var self = this;
    self.id = ko.observable(id);
    self.date = ko.observable(date);
    self.volume = ko.observable(volume);
};

function ForecastViewModel() {
    var self = this;
    self.dates = ko.observableArray([]);
}

I feel like I should be using a foreach binding, but can’t figure out how to wrap the grid after the 7th column.

Any ideas?

  • 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-09T08:45:31+00:00Added an answer on June 9, 2026 at 8:45 am

    Link to demo : JsFiddle

    Create 2 template and a container

    <div id="container" ></div>
    

    First one is responsible for rendering date box :

    <script id="datebox" type="text/x-jquery-tmpl">
     ... 
    </script>
    

    Second one is resposible for 7 days :

    <script id="week" type="text/x-jquery-tmpl">
      <div data-bind="template: { name : 'datebox'  , foreach : dates }">
    </script>
    

    Then prepare a function that splits the date array and apply the templates like this :

    function splitDateArray() {
    
      /** Splice observable Array 4 or 5 subArray depends on the month of year **/
      var subArray_one   /* contains 7 date */
      var subArray_two   /* contains 7 date */
      var subArray_three /* contains 7 date */
      var subArray_four  /* contains 7 date */
      var subArray_five  /* contains 0-3 date */
    
      /** Then create dynamic dom object and apply each array indivually to week template **/
    
      var week1=$("<div id='w1'></div>");
      $("#container").append(week1);
    
      ko.applyBindingsToNode($("#w1").get(0) , { template: { name: 'week', data: subArray_one  } });
    
      ... apply the same pattern for other arrays ...
    
      ko.applyBindingsToNode($("#w2").get(0) , { template: { name: 'week', data: subArray_two  } });
    
      ko.applyBindingsToNode($("#w3").get(0) , { template: { name: 'week', data: subArray_three  } });
    
      ko.applyBindingsToNode($("#w4").get(0) , { template: { name: 'week', data: subArray_four  } });
    
      ko.applyBindingsToNode($("#w5").get(0) , { template: { name: 'week', data: subArray_five  } });
    

    }

    Summary :

    Use ko.applyBindingsToNode function to render sub templates after prepared your array. Thats my first thought. There can be more efficient solutions.

    EDIT :

    Here is a simple implemantation of the idea without details : JsFiddle

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

Sidebar

Related Questions

Hoe can I do following thing without using a VIEW from one Query. !--CREATE
How would I create the following scenario that rails can provide for carrierwave, using
I am using the following code to create calendar controls on textboxes that have
I can create the following and reference it using area[0].states[0] area[0].cities[0] var area =
In the following example i can create an object dynamically via a string; however,
If I create following the Servlet 3.0 specification a web application fragment how can
How can I create an anonymous and curried function in Scala? The following two
How can i create an attribute with a namespace? To get the following output?
How can I create a const boost matrix? The following did not work: const
Tell me please, how can I create xsd schema, which successfully validate the following

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.