Skip to content
ericmbarnard edited this page Jan 20, 2012 · 15 revisions

In KoGrid, you can define what columns your grid will display using the colDefs configuration option.

A colDef (short for ColumnDefinition) includes the following properties:

  • field (required): The property that the column should bind to
  • displayName (optional) : The name that the column header will display (defaults to field if not provided)
  • width (optional) : The width (px) that you would like the column to display (outerWidth of the column)
  • cellTemplate (optional) : The id of the <script type="text/html"> tag that contains the cell template you want this column to use

An example of defining the columns of a grid looks like:

<div data-bind="koGrid: { data: myDataSource, 
                          colDefs: [{ field: 'firstName', displayName: 'First Name', width: 90 },
                                    { field: 'lastName', displayName: 'Last Name', width: 80 } ]">
</div>