Search code examples
kendo-ui-angular2

Disable sorting on one or more grid columns in Kendo UI for Angular


I'm playing around a bit with Kendo UI for Angular and can't seem to find an easy way to disable sorting on specific columns of a grid.

There's an allowUnsort in sort-settings.d.ts, but I'm uncertain on how to use this (and this appears to relate to removing sorting afterwards, not from the start).

Or perhaps I'm simply using the grid wrong, that's also possible..

My situation is as follows:

I'm trying to use a grid to display some rows, and depending on the type of data, it should render a different icon in the first column. Also, I'm not using a 'real' header in that column, but replaced it with a button to create a new row.

To get my button in the header, I use a <template kendoGridHeaderTemplate ...>...</template>. This always seems to add a link around the header cell if sortable is enabled, which is what I'm trying to avoid (in some cases).

Is there a way around this?


Solution

  • Setting [sortable]="true" for the Grid component will enable sorting globally. Then you can fine-tune which column has sorting by disabling it per column, i.e [sortable]="false"

    Here is a quick example: http://plnkr.co/edit/hLbzC5jKJwVdMtRmh0cH?p=preview