Book Image

Mastering KnockoutJS

By : Timothy Moran
Book Image

Mastering KnockoutJS

By: Timothy Moran

Overview of this book

Table of Contents (16 chapters)
Mastering KnockoutJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

KoGrid


KoGrid is a plugin that creates a binding that renders tabular data. As its GitHub page notes, it is "a direct knockout port of ng-grid which was originally inspired by KoGrid, which was inspired by SlickGrid." Its history might have been affected by the grandfather paradox.

In its most basic operation mode, KoGrid can bind against an array of objects, turning their properties into columns and their values into cells:

var vm = {
      people: ko.observableArray([{name: "Moroni", age: 50},
                                      {name: "Tiancum", age: 43},
                                      {name: "Jacob", age: 27},
                                      {name: "Nephi", age: 29},
                                      {name: "Enos", age: 34}])
   }
<div class="gridStyle" data-bind="koGrid: { data: people }"></div>

You can see this example in the cp8-kogrid branch. Except for needing to manually specify, through style of CSS, the dimensions of the grid itself, everything else...