I have an object with data I that I want to use to fill a list. When someone clicks a link it triggers the javascript below and the value from e.view.params.street_id is taken (for example: 2) and filters the obj's street_id field. I then want to take data from the filtered objects in the "addresses" parameter, and fill #template (below) with the data from that. Can I do that? and how?
<script id="template" type="text/x-kendo-template">
<span>${street_number}</span>
<span>${notes}</span>
<span>${notes}</span>
</script>
var
obj = [
{
"street_id"
:
"1"
,
"street_name"
:
"First St"
,
"addresses"
: [
{
"street_number"
:
"100"
,
"notes"
:
"Example notes..."
},
{
"street_number"
:
"101"
,
"notes"
:
""
}
]
},
{
"street_id"
:
"2"
,
"street_name"
:
"Second St"
,
"addresses"
: [
{
"street_number"
:
"200"
,
"notes"
:
""
},
{
"street_number"
:
"201"
,
"notes"
:
"Test notes..."
}
]
}
];
var
template = kendo.template($(
'#template'
).html());
var
dataSource =
new
kendo.data.DataSource({
data: obj,
filter: {
field:
'street_id'
,
operator:
'eq'
,
value: e.view.params.street_id
},
change:
function
() {
$(
'#streets'
).html(kendo.render(template,
this
.view()));
}
});
dataSource.read();