This is a migrated thread and some comments may be shown as answers.

server side sorting by a different field

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Remco
Top achievements
Rank 1
Remco asked on 13 Sep 2012, 10:04 AM
Hello,



I use the grid bound to remote data (a SharePoint list odata/rest feed). As you click a column header to sort that column, I would like to sort by a different field than is displayed in that column. I could not find documentation how to do this. I can set the display field on a column in the grid, but I cannot set a different field to sort that column by. Is this supported?



kind regards



Remco

1 Answer, 1 is accepted

Sort by
0
Remco
Top achievements
Rank 1
answered on 25 Sep 2012, 10:08 AM
I managed to get this implemented by defining a column as follows:

{ field: "Severity.SortOrder", title: "Severity", template: "#=Severity.Title#" }

But I wanted the column to be not editable. Strangely this editable setting is not defined on the column, but in the schema of the model. Like so:

kendo.data.Model.define({
    id: "Id",
    fields: {
        Id: { type: "number", editable: false, nullable: true },
        Title: { type: "string" },
        SeverityId: { type: "number", editable: false, validation: { required: true } },
        Severity: { editable: false, validation: { required: true } },
        "Severity.SortOrder": { editable: false },
    }
})

I had to add a field for "Severity.SortOrder" just to be able to set editable to false. But "Severity.SortOrder" is not a real field. The real fields are Severity and SeverityId. So it looks rather strange having to define a field "Severity.SortOrder" just to make the column not editable. Seems like a design flaw anyway. Surely you should define on the column whether the column is editable or not. You should not have to define that on the model. What if the model is used in multiple grids where in one grid the column is editable and the other grid the column is not editable?
Tags
Grid
Asked by
Remco
Top achievements
Rank 1
Answers by
Remco
Top achievements
Rank 1
Share this question
or