Hello
I was wondering how I can achieve dynamic multiple column headers. Currently I have a product followed by six columns , each a pair of Quantity and Price for past three years from selected year. I wish to group each Quantity & Price of each year under a title of the year . See example.
Before the update with multiple headers I as injecting a <tr> rows with javascript after the first table element, but this doesnt export with grid.
Help much appreciated
columns.Group(group => group
.Title("Contact Info") ****** DYNAMIC HOW **** ????
.Columns(info => {
info.Bound(x => x.ContactTitle).Width(200);
info.Bound(x => x.ContactName).Width(200);
info.Group(g => g.Title("Location")
.Columns(location =>
{
location.Bound(c => c.Country).Width(200);
location.Bound(c => c.City).Width(200);
})
);
info.Bound(x => x.Phone);
})
);
I was wondering how I can achieve dynamic multiple column headers. Currently I have a product followed by six columns , each a pair of Quantity and Price for past three years from selected year. I wish to group each Quantity & Price of each year under a title of the year . See example.
Before the update with multiple headers I as injecting a <tr> rows with javascript after the first table element, but this doesnt export with grid.
Help much appreciated
columns.Group(group => group
.Title("Contact Info") ****** DYNAMIC HOW **** ????
.Columns(info => {
info.Bound(x => x.ContactTitle).Width(200);
info.Bound(x => x.ContactName).Width(200);
info.Group(g => g.Title("Location")
.Columns(location =>
{
location.Bound(c => c.Country).Width(200);
location.Bound(c => c.City).Width(200);
})
);
info.Bound(x => x.Phone);
})
);
5 Answers, 1 is accepted
0
Hi Jako,
You can use a loop to create the appropriate column groups similar to the following:
Regards,
Rosen
Telerik
You can use a loop to create the appropriate column groups similar to the following:
for
(var idx = 0; idx < 3; idx++)
{
columns.Group(group => group
.Title(DateTime.Now.AddYears(idx).ToString(
"yyyy"
))
.Columns(info =>
{
info.Bound(x => x.ContactTitle).Width(200);
info.Bound(x => x.ContactName).Width(200);
info.Group(g => g.Title(
"Location"
)
.Columns(location =>
{
location.Bound(c => c.Country).Width(200);
location.Bound(c => c.City).Width(200);
})
);
info.Bound(x => x.Phone);
})
);
}
Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

Ali
Top achievements
Rank 1
answered on 28 Apr 2015, 06:42 AM
Can we get a complete working sample project for this?? Or more details? We have similar requirement, but year has to be picked from database..
0
Hi Roohul,
I'm afraid that we do not have such example available.
The snippet in question creates 3 column groups, one for each sequential year, where the each group title is the year.
If you want to create multiple column groups base on the array of years loaded from the database. You will need to store them in a separate array, for example attached to the ViewModel, iterate the array and construct the column definition. For example:
Regards,
Rosen
Telerik
I'm afraid that we do not have such example available.
The snippet in question creates 3 column groups, one for each sequential year, where the each group title is the year.
If you want to create multiple column groups base on the array of years loaded from the database. You will need to store them in a separate array, for example attached to the ViewModel, iterate the array and construct the column definition. For example:
foreach
(var year
in
(
string
[])ViewBag.Years)
{
columns.Group(group => group
.Title(year)
.Columns(info =>
{
//.... bound column declaration
})
);
}
Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

harmit
Top achievements
Rank 1
answered on 02 May 2016, 10:40 AM
how to bind column data dynamically with respect to title?
0
Hello harmit,
I'm afraid I could not understand your question. Could you please clarify? How it differs from the scenario discussed in this thread so far?
Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!