How can i remove the expand arrow in kendo ui treeview if there are no child's to display

纵饮孤独 提交于 2019-12-08 06:45:38

问题


I am using kendo ui treeview. I am loading the treeview dynamically from the database. But my issue is i am getting the expand error if there are no child's to display. How can i remove the expand arrow.

Regards,

Sri


回答1:


There is a configuration field of the HierarchicalDataSource schema.model object called hasChildren you can add a boolean property to your model which indicates if the your model has items.

This way when the TreeView creates its elements it will check that property (or call the function - you could for example return if the items.leght is greater than zero) and if the returned value is false it wont create the expand arrow in front of the item.

Check this demo.




回答2:


for an example, I have declared my function like this in my Kendo Ui TreeView :

 var inline = new kendo.data.HierarchicalDataSource({
        data: @Html.Raw(dataSource),
        schema: {
            model: {
                children: "Children",
                hasChildren: function(e) {
                    var test = e.Children.length;
                    return test > 0; 
                }
            }
        }
    });

And for my, it works perfectly !



来源:https://stackoverflow.com/questions/13564797/how-can-i-remove-the-expand-arrow-in-kendo-ui-treeview-if-there-are-no-childs-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!