Hi,
What is the best way to group by a field in a ListView?
I'd like to have something along the lines of this
Species: Human
1: Toby
2: Rob
Species: Dog
3: Harry
4: Rover
Species: Cat
5: Tickles
The model schema is as below
ID Name Species
1 Toby Human
2 Rob Human
3 Harry Dog
4 Rover Dog
5 Tickles Cat
<
script
type
=
"text/x-kendo-tmpl"
id
=
"template"
>
<
div
class
=
"person"
>
<
div
class
=
"id"
>#:ID#</
div
>
<
div
class
=
"name"
>#:Name#</
div
>
</
div
>
</
script
>
<
div
id
=
"persons"
>
@(Html.Kendo().ListView<
Person
>()
.Name("persons")
.TagName("div")
.ClientTemplateId("template")
.DataSource(ds => ds
.Model(m => m.Id(p => p.ID))
.Read(r => r.Action("PersonsRead", "Home"))
.Group(g => g.Add(p => p.Species))
)
)
I managed to get as far as the above, but this throws an error as it is passing the Species field and value to the client template from the Group method.
Any ideas?