DataSource of Undefined

2 posts, 0 answers
  1. Mohammad Reza
    Mohammad Reza avatar
    2 posts
    Member since:
    Apr 2016

    Posted 25 Nov 2017 Link to this post

    in need help to fix error this function
    this error show me in console
    Uncaught TypeError: Cannot read property 'dataSource' of undefined

    function treeview_getCheckedItems(treeId) {
        function _checkedNodeIds(nodes, checkedNodes) {
            for (var i = 0; i < nodes.length; i++) {
                if (nodes[i].checked) {

                if (nodes[i].hasChildren) {
                    _checkedNodeIds(nodes[i].children.view(), checkedNodes);
        var treeView = $("#" + treeId).data("kendoTreeView");
        var treeData = treeView.dataSource.view();
        var checkedNodes = [];
        _checkedNodeIds(treeData, checkedNodes);
        return checkedNodes;
  2. Ivan Danchev
    Ivan Danchev avatar
    2152 posts

    Posted 28 Nov 2017 Link to this post


    Assuming you get this exception when this line is executed:
    var treeData = treeView.dataSource.view();

    this means you don't have a proper reference to the TreeView. This could be due to passing an incorrect id value here:
    var treeView = $("#" + treeId).data("kendoTreeView");
    so we can suggest checking whether an element with this id exist by the time you are trying to access it: $("#" + treeId)

    If you post a runnable dojo example, which demonstrates the issue we would be able to inspect your code and check why the treeView variable does not hold a valid reference to the widget.

    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top