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

Sorting on concatenated column cell

1 Answer 385 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Guillermo
Top achievements
Rank 1
Guillermo asked on 22 May 2013, 12:20 AM
In  my case of Kendo grid, datasource is from JSON data. and part of data feed is like following:
"User": {
...
"FirstName": "Joe",
"LastName": "Doe",
"Phone": null,
...
}

And I need to display full name  in column of "Name" in kendo grid
  columns: [
                { field: "User.FirstName+' '+ User.LastName", title: "Name"},
                ...
   ]
and I also set sortable to be true for this grid. And that works well, the grid shows cell as "Joe Doe"

However, the grid doesn't sort by "Name" column and when I tried to click header of column "Name",  it returns error on kendo.core.min.js 
"(function($,undefined){function Class(){}function compilePart(e,t){if(t)return"'"+e.split("'").join("\\'").split('\\"')......."

Could you let me know where I did wrong? Thanks,


1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 22 May 2013, 12:41 PM
Hi Guillermo,

The Kendo UI Grid (actually the Kendo UI DataSource) sorts by data fields, not by Grid columns. Multiple data fields can be displayed in a single column by using column templates, but still, one Grid column can be associated with only one data field, which is used for sorting and filtering. Specifying multiple field names at the same time is not supported.

In your case you have two options:

1. Modify the datasource, so that the first name and last name belong to the same field in the JSON.

2. Use some hackish workaround, which will include intercepting click events on the header cell, preventing the default sort action, constructing a custom sort expression with two fields and executing the sort() method of the Grid datasource manually.

Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Guillermo
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or