I have a grid which I define declaratively. It works well except that the column sorting interprets the columns as strings, whereas I wish for some columns to be sorting as numerical values.
Below is my grid definition.
The column I am interested in sorting in numerical order is "incident_count". I have tried specifying a type: "number" attribute to the column but it did not work.
<div id="PatrolRecords">
<div data-filterable='{ "mode": "row" }'
data-role='grid'
data-sortable='true'
data-detail-template='patrolDetailTemplate'
data-detail-init='detailInit'
data-bind='source: reportData.Patrols, events: {excelExport: excelExportHandler}'
data-pageable='{ "pageSize": 10 }'
data-toolbar='["excel"]'
data-excel='{ "fileName": "Patrols.xlsx", "allPages": "true" }'
data-columns='[
{
field: "patrol_id_plain",
title: "Patrol ID",
filterable: false,
width: 70
},
{
field: "tour_name",
title: "Tour",
filterable: { cell: { operator: "contains" } }
},
{
field: "location_name",
title: "Location",
filterable: { cell: { operator: "contains" } }
},
{
field: "client_company",
title: "Company",
filterable: { cell: { operator: "contains" } }
},
{
field: "address",
title: "Address",
template: kendo.template($("#addressTemplate").html()),
filterable: { cell: { operator: "contains" } }
},
{
field: "end_date_seconds",
title: "Date & Time",
template: kendo.template($("#dateTemplate").html()),
filterable: false
},
{
field: "patrolled_by",
title: "Patrolled By",
filterable: { cell: { operator: "contains" } }
},
{
field: "checkpoints",
title: "Checkpoints",
template: kendo.template($("#checkpointsTemplate").html()),
filterable: false,
width: 90
},
{
field: "incident_count",
title: "Incidents",
filterable: false,
type: "number",
width: 70
},
{
title: "GPS",
template: kendo.template($("#gpsTemplate").html()),
filterable: false,
width: 50
},
{
title: "",
template: kendo.template($("#viewLinkTemplate").html()),
filterable: false,
width: 60
},
]'>
</div>
</div>