Accessing list of a model in Templates

2 posts, 0 answers
  1. sho
    sho avatar
    24 posts
    Member since:
    Mar 2007

    Posted 16 Feb 2015 Link to this post

    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>




  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 18 Feb 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top