Is there anyway to provide default grouping when the grid is rendered on the view? For example, in the grid below, I want to group by Type, by default. Thanks.
@(Html.Kendo().Grid<SomeModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.TYPE).Title("Type");
columns.Bound(p => p.NAME).Title("Name");
columns.Bound(p => p.CITY).Title("City");
})
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.Read(read => read.Action("GetInfo", "Summary"))
)
.Groupable (// group by first column)
@(Html.Kendo().Grid<SomeModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.TYPE).Title("Type");
columns.Bound(p => p.NAME).Title("Name");
columns.Bound(p => p.CITY).Title("City");
})
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(100)
.Read(read => read.Action("GetInfo", "Summary"))
)
.Groupable (// group by first column)
5 Answers, 1 is accepted
1
Victor
Top achievements
Rank 1
answered on 11 Jul 2012, 05:39 PM
Nowadays you configure it using the datasource, for example
.DataSource(ds => ds.Ajax().Group(g => g.Add(c => c.Name)))
/Victor
.DataSource(ds => ds.Ajax().Group(g => g.Add(c => c.Name)))
/Victor
0
Ashwin
Top achievements
Rank 1
answered on 11 Jul 2012, 06:22 PM
That worked. Thanks!
0
Raj
Top achievements
Rank 1
answered on 28 Feb 2017, 03:15 PM
Hello Victor
I would like to display only the value when default grouping is enabled. Instead of displaying the column name and its corresponding value i would like to have only value to be display. In the attached file you can see Description and Facility Name are displayed on all groups, i would like to have only value without Description and Facility Name.
Thanks
Raj
0
Hello Raj,
You can use the ClientGroupHeaderTemplate("#: value #") in the respective columns configurations, e.g.:
You can find more information about the Grid columns.groupHeaderTemplate and the available field references inside the template in the following API reference:
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.groupHeaderTemplate
I hope this helps.
On a side note, this thread is rather outdated, and in general I can suggest starting a new one in such cases, so that all information in the subsequent discussion will be up-to-date, and will be relevant to the current Kendo UI version. Thank you in advance.
Regards,
Dimiter Topalov
Telerik by Progress
You can use the ClientGroupHeaderTemplate("#: value #") in the respective columns configurations, e.g.:
ClientGroupHeaderTemplate(System.String)
Sets the client group template for the column.
Parameters
value System.String
The template
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
.Name(
"grid"
)
.Columns(columns =>
{
columns.Bound(c => c.ContactName)
.ClientGroupHeaderTemplate(
"#: value #"
)
.Width(240);
columns.Bound(c => c.ContactTitle)
.ClientGroupHeaderTemplate(
"#: value #"
);
...
})
...
.DataSource(dataSource => dataSource
.Ajax()
.Group(g => g.Add(c => c.ContactName))
.Read(read => read.Action(
"Customers_Read"
,
"Grid"
))
.PageSize(20)
)
)
You can find more information about the Grid columns.groupHeaderTemplate and the available field references inside the template in the following API reference:
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-columns.groupHeaderTemplate
I hope this helps.
On a side note, this thread is rather outdated, and in general I can suggest starting a new one in such cases, so that all information in the subsequent discussion will be up-to-date, and will be relevant to the current Kendo UI version. Thank you in advance.
Regards,
Dimiter Topalov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which
deliver the business app essential building blocks - a grid component,
data visualization (charts) and form elements.
0
Raj
Top achievements
Rank 1
answered on 03 Mar 2017, 02:42 PM
Thanks Dimiter.
It Worked and yes i will open new threads if there are any outdated posts.
Thanks
Raj