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

Grid Server Grouping By Id

1 Answer 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Veteran
Marcin asked on 11 Sep 2014, 02:20 PM
Hello
I have following data:

user_id, user_first_name, user_surname, some_other_data

On Grid I'm displaying it in following way

UserDisplayName (user_first_name + ' '+ user_surname), Some Data

Now I would like to group data by user. So in fact on database level it should be grouped by user id but then it should display in grid group header proper user display name.

I know how to achieve such grouping by simply replacing proper memeber in group descriptor on DataSourceRequest object, but Then group header is wrong.
Probably it would be possible to somehow on fly replace that values?

But I believe it would be still a problem with sorting.

Is such server grouping is possible? In linq I can define multiple columns to group, but have no idea how to apply that to data source.

Kind Regards
Marcin

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 15 Sep 2014, 11:25 AM
Hi Marcin,

Basically, the group header has access to the name of the field that the data is grouped by and its value. In the current scenario you could use the groupHeaderTemplate to call a custom function that returns a string, matching the ID. For example: 
{field: "user_id", groupHeaderTemplate: "#=getStudentNameByID(value)#"}
...
 
function getStudentNameByID(user_id){
    //custom implementation ...
    name = "test"
    return name;
}

Implementing this on the server-side is possible, however that would require a custom solution that is beyond the scope of our support services.

Regards,
Alexander Popov
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
Marcin
Top achievements
Rank 1
Veteran
Answers by
Alexander Popov
Telerik team
Share this question
or