Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'replace' of undefined with KendoTreeView`

Below is my KendoUI tree view, I am using templates to show edit link on each node, but I am getting this error: "Uncaught TypeError: Cannot read property 'replace' of undefined "

 @section scripts{
        <script src="~/scripts/kendo.all.min.js"></script>

        <script type="text/javascript">

          var  territory = new kendo.data.HierarchicalDataSource({
                transport: {
                    read: {
                        type:'POST',
                        url: rootURL + "Territory/AllTerritories",
                        dataType: "json"
                    }
                },
                schema: {
                    model: {
                        id: "ID",
                        hasChildren: "HasChildren",
                        children: territory

                    }
                }
            });

            $("#treeview").kendoTreeView({
                dataSource: territory,
                dataTextField: "Name",
                dataValueField: "ID",
                template: kendo.template($("#treeview-template").html())
            });

        </script>



    }

    <script id="treeview-template" type="text/kendo-ui-template">
        #
        <a class='show-link' href='\#'><image src="/Content/images/select2.png"></a> #
    </script>
    <style scoped>
        #territoryTree {
            text-align: center;
        }
        #treeview .k-sprite {
            background-image: url("../content/default/coloricons-sprite.png");

        }
        .rootfolder {
            background-position: 0 0;
        }
        .demo-section {
            display: inline-block;
            vertical-align: text-bottom;
            min-width: 320px;
            min-height: 300px;
            text-align: left;
            margin: 0 2em;
        }
    </style>

Any solutions?? Please help

like image 601
user3014311 Avatar asked Sep 30 '22 11:09

user3014311


1 Answers

jquery can't find the element with Id #treeview-template when you say

kendo.template($("#treeview-template").html())

then first it will try to find the html element with the Id #treeview-template and then it will move forward. Try the F12 and the console by writing $("#treeview-template").html() in the console see if it can or cannot find the element

like image 151
visar_uruqi Avatar answered Oct 11 '22 17:10

visar_uruqi