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

Is it possible to group on text values of the foreign key

1 Answer 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 15 Jul 2013, 11:28 PM
Hi, Foreign key columns in the grid are not being grouped by text rather by foreign key id. Any recommendations as to how can we group by text of the foreign key col.

Thanks

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 17 Jul 2013, 09:15 AM
Hi Rick,

 
Please note that sorting/grouping by the text of the ForeignKeyColumn is not supported out-of-the-box and it will require custom solution. For example you can create hidden column (by adding additional property to the model) which to contain the text representation of the ForeignKeyColumn - please check the example below with additional information:

$(function () {
    var grid = $("#grid").data("kendoGrid");
    //find the ForeignKeyColumn and replace it's data-field attribute
    //to point to the hidden column that contains the text represantation
    var menu = grid.thead.find("th[data-field='CategoryID']").attr("data-field", "CategoryName").data("kendoColumnMenu");
    menu.field = "CategoryName";
});
Kind Regards,
Vladimir Iliev
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
Rick
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or