Skip to content
ericmbarnard edited this page Apr 12, 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
  • cellClass (optional) : The css class you would like to be applied to all data cells in that column
  • headerClass (optional) : The css class you would like to be applied to the header in that column

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 },
                                       { field: 'age', cellClass: 'ageCell', headerClass: 'ageHeader' ]">
</div>
Clone this wiki locally