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

Grid and extended detail templates

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dimm
Top achievements
Rank 1
Dimm asked on 04 Jul 2012, 07:57 PM
$(document).ready(function(){
     
    var localDataSource = new kendo.data.DataSource({
        data: [ {
                name: "Dmitry",
                year: 1987,
                id: 1
            }, {
                name: "Dash",
                year: 1994,
                id: 2
            }, {
                name: "Sam",
                year: 1954,
                id: 3
            }
        ]
         
    });  
     
    var detailsSource = new kendo.data.DataSource({
        data:[
            {
                name: "Dmitry",
                year: 1987,
                id: 1,
                address:'Luga',
                phnom:'+380995668745'
            },
            {
                name: "Dash",
                year: 1994,
                id: 2,
                address:'Brest',
                phnom:'+380955569874'
            },
            {
                name: "Sam",
                year: 1954,
                id: 3,
                address:'Praha',
                phnom:'+380679964382'
            }
        ]
    });
 
    $("#grid").kendoGrid({
        dataSource: localDataSource,
         
        selectable: "multiple, row",
        sortable: true,               
        detailTemplate: kendo.template($("#template").html()),               
        detailInit: details,                      
        columns: [
            {
                field: "name",
                title: "Name"
            },
            {
                field: "year",
                title: "Home address",
            }]
    });
     
    function details(e){
        // @todo get details by id e.data.id
        detailsSource.read();
    }
})
Template:
    <script type="text/x-kendo-template" id="template">
    <div>
        <ul>
            <li><label>Name:</label>#= name #</li>
            <li><label>Year:</label>#= year #</li>
            <li><label>Address:</label>#= address #</li>
            <li><label>Phone:</label>#= phnom #</li>
        </ul>
    </div>
</script>
When I try get details I was get an error: Uncaught ReferenceError: address is not defined. 
How to solve this problem?

1 Answer, 1 is accepted

Sort by
0
Dimm
Top achievements
Rank 1
answered on 05 Jul 2012, 07:44 PM
I need like this: call detailInit that fires another source and the data in the detailtemplate are updated from the last datasourse
Tags
Grid
Asked by
Dimm
Top achievements
Rank 1
Answers by
Dimm
Top achievements
Rank 1
Share this question
or