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

Custom sort order for group headers in Grid

3 Answers 625 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clinton Smyth
Top achievements
Rank 1
Clinton Smyth asked on 13 Sep 2012, 06:37 PM
Hi

Is there a way to specify the sort order for group headers in a grid?

I am returning the sort order as a number in another field and would like to display the groups sorted according to this field.  Additionally I do not want to display the grouped field in the table as a column.

As a work around, I've concatenated the sort field and group field values together and used that to group by but, although it works, it doesn't look good.  I thought of using the groupHeaderTemplate to then remove the sort prefix before displaying it but seeing as I don't want to display this info in a column, I don't have a way to specify the template.

Is there a way to specify a field in the columns section of a grid but not display it as a column (e.g. field "Section", hide: true) ?

Please help.

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 14 Sep 2012, 07:00 AM
Hello Clinton,

I'm afraid that you cannot sort groups on different then the group field.

You may set the column as hidden by setting hidden option to true:

columns: [ {
    field: "FirstName",
    title: "First Name",
    hidden: true
}
/*..*/
]

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Clinton Smyth
Top achievements
Rank 1
answered on 14 Sep 2012, 04:29 PM
Thanks, I did the following and it works well for displaying the grid (I was working with an earlier version of kendoui which didn't have the 'hidden' option).

columns: [
{
    field: "SectionGroup",
    width: "90px",
    hidden: true,
    groupHeaderTemplate: "Section: #= value.substring(3) #"
},
...
]

The problem I now see is that the hidden column does not remain hidden when editing on the edit popup.  I set the field to 'editable:false' in the datasource but it still displays the field and it's value (albeit only as text).

How do I get the field to remain hidden when editing?
0
Accepted
Rosen
Telerik team
answered on 17 Sep 2012, 08:29 AM
Hi Clinton,

Currently, you will need to manually hide the label and the editor for the field. This can be achieve via the Grid edit event. Please refer to this small sample which demonstrates a possible implementation.

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