-
Notifications
You must be signed in to change notification settings - Fork 129
Defining Columns
ericmbarnard edited this page Mar 7, 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 tofield
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>