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

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

A columnDef (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, 
                          columnDefs: [{ field: 'firstName', displayName: 'First Name', width: 90 },
                                       { field: 'lastName', displayName: 'Last Name', width: 80 } ]">
</div>
Clone this wiki locally