This is a migrated thread and some comments may be shown as answers.

dataSource filter, then return data deeper in object

0 Answers 85 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Vince
Top achievements
Rank 1
Vince asked on 20 Sep 2012, 10:34 PM
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>
</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();

No answers yet. Maybe you can help?

Tags
Data Source
Asked by
Vince
Top achievements
Rank 1
Share this question
or