I'd like to display the detail of a record inside a list view within my detail view. I'm trying to use an MVVM source binding and a data-template attribute to specify the list items and how they should look. Like this:
Unfortunately it appears that the Kendo ListView component is interfering with the source binding because it expects to be bound to an array and have the data-template point to a template for each element in the array.
Is there any way to bind a list view to a flat structure like I'm trying to do here? I'd do <span>s with data-bind="text: ..." bindings, but the display logic is a bit too complicated for simple data bindings...
Thanks,
Jonathan
<
script
>
var model = kendo.observable({
user: {
firstName: 'Jonathan',
lastName: 'Marston',
age: 29,
isSubscribed: true,
subscriptionType: 'monthly'
subscriptionDate: new Date(2012, 12, 12)
}
});
</
script
>
<
script
id
=
"detailTemplate"
type
=
"text/html"
>
<
li
><
label
>First Name</
label
>#: data.firstName #</
li
>
<
li
><
label
>Last Name</
label
>#: data.lastName #</
li
>
<
li
><
label
>Age</
label
>#: age #</
li
>
# if (data.isSubscribed) {
if (data.subscriptionType == 'monthly') { #
<
li
>Monthly subscription</
li
>
# } else { #
<
li
>Yearly subscription</
li
>
# } #
<
li
><
label
>Subscribed</
label
> #: kendo.format(data.subscriptionDate, 'MM/dd/yyyy') #</
li
>
# } else { #
<
li
>Not subscribed</
li
>
# } #
</
script
>
<
div
data-role
=
"view"
data-model
=
"model"
>
<
ul
data-role
=
"listview"
data-template
=
"detailTemplate"
data-bind
=
"source: user"
>
</
ul
>
</
div
>
Is there any way to bind a list view to a flat structure like I'm trying to do here? I'd do <span>s with data-bind="text: ..." bindings, but the display logic is a bit too complicated for simple data bindings...
Thanks,
Jonathan