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

Using same template on template

1 Answer 98 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Jaime
Top achievements
Rank 1
Jaime asked on 14 Jul 2017, 09:06 AM

Hi!, i'm trying to use a template into the same template. This is the code:

<script id="nestedTemplate" type="text/x-kendo-template">
    <li><b>#: _folderName #</b>
    <ul data-template="nestedTemplate" data-bind="source: _folders"></ul>
    <ul data-template="filesTemplate" data-bind="source: _files"></ul>
    </li>
</script>

json (remote)

{
        "_folderName": "Dpto CGE",
        "_folders": [
          {
            "_folderName": "Informes Test",
            "_folders": [
              
            ],
            "_files": [
              {
                "OriginalPath": "Comparativa de Planificación Mensual con Producción Hasta Marzo 2013.sql"
              },
              {
                "OriginalPath": "Comparativa de Planificación Mensual con Producción.sql"
              },
              {
                "FullPath": "\\\\192.168.10.6\\pfolder$\\jgperez\\Control De Gestión\\Informes Gema\\Obras.xls"
              }
            ]
          }

So, the template is calling itself each _folders is found but it doesn't works: : e.bind is not a function

Can i use nested templates with MVVM?

Thanks.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 18 Jul 2017, 08:40 AM
Hello Jaime,

On the following Dojo example you will find a simple source binding to array, where a nested template is used for the list items. 

In such cases, a single root element should be used in the template, because otherwise the binding will not work as expected. In the provided code sample the nested template looks correct. You can check your upper-level templates for the same requirement. You can find more information in the following source bindings article.

Please review the provided implementation and and try to incorporate it in your project. In case the issue continues to persist, you can modify the provided Dojo example or create a new one and send it back to us for a review, so that we can examine it locally and provide you with further assistance.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
MVVM
Asked by
Jaime
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or