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

Accessing list of a model in Templates

1 Answer 45 Views
Templates
This is a migrated thread and some comments may be shown as answers.
sho
Top achievements
Rank 1
sho asked on 16 Feb 2015, 01:51 PM
Hi,

I have issue with looping through the list of a models in template.  I am binding the below template to listview

Model : 
     ModelClass()
{
           ClassId
           ClassName
           ClassSize
           List<ModelStudents>()
}

ModelStudents()
{
     StudName
     StudAge
     StudGender
     List<ModelMarks>
}

ModelMarks()
{
    Marks1
    Marks2
    Marks3
}

A model is passed to the view and I can get the parent element like this. But how to get the collections from the parent element.

<script type="text/x-kendo-template" id="mytesttemplate">
           #=ClassId#</br/>
            #=ClassName#</br/>
           #=ClassSize#</br/>
</script>




1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 18 Feb 2015, 08:56 AM
Hi Shobha,

the javascript objects are unaware of the parent <> child relationship - you should manually assign a reference to the parent object in order to access it in the template. 

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
sho
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or