In addition to the key
and field
properties, there are a lot of other properties that can be configured for each Column definition. This recipe will explain the default and valid values for the Column definition, and the configuration changes.
The simplest way to define DataTable Columns is by defining the key
only:
var myColumnDefs = [ {key: 'key1'}, {key: 'key2'}, {key: 'key3'} ];
The most common use is to define the key, field, and label:
var myColumnDefs = [ {field: 'fieldName1', label: 'Field Name1', key: 'key1'}, {field: 'fieldName2', label: 'Field Name2', key: 'key2'}, {field: 'fieldName3', label: 'Field Name3', key: 'key3'} ];
And here is an example that makes use of each of the configuration properties:
myColumnDefs = [ { field: 'a', key: "city", label: "City", abbr: 'us city', sortable: true, maxAutoWidth: 100, selected: true }, { field: 'b', key: "state", label: "State", className: 'allCaps', resizeable:true, sortable: true, sortOptions:...