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

Data available to columns.groupHeaderTemplate

1 Answer 262 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 16 Jan 2013, 03:56 PM
I recently had cause to configure a kendo mobile listview with a headerTemplate for grouped data. The reason was that I wanted to group by one field but use another for the displayed label since the former had the correct sort order. The template looked like this:
<script type="text/x-kendo-templ" id="header-template">
${data.items[0].section}
</script>

Where 'section' was a defined field in my data source.

When I try the same approach with a kendo web grid then an error 'undefined' is thrown. I've googled and checked the docs and apart from references to 'value', 'max', 'sum' I can't seem to find anything that clarifies what is available to the template at this point. Ideally I want to make the same type of reference as works for the mobile listview.

Thanks,

Mark.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 18 Jan 2013, 03:28 PM
Hello Mark,

The data available in group header template are the field name, value and group aggregates. The list of group items is not available like in the mobile ListView.

As a workaround I can suggest to call a JavaScript function from within the template which will loop through the dataSource's view to find list of group items. Here is an example:
groupHeaderTemplate: "#getItems(value)#" }
 
function getItems(value) {
    var grid = $("#grid").data("kendoGrid"),
        view = grid.dataSource.view();
 
    for (var i = 0; i < view.length; i++) {
        if(view[i].value === value) {
            console.log(value, view[i].items);
        }
    }
}

I hope this will help.

Kind regards,
Alexander Valchev
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
Mark
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or