AngularJS 的 DXTreeview 将不允许扩展分支
DXTreeview with AngularJS will not allow branches to be expanded
我有一个包含以下内容的 MVC5 项目 Index.aspx
当我 运行 VS2013 中的项目时,我只能看到树的顶部分支,没有明显的方法来展开它们。
Resharper 表明我的参考资料没问题。
我是 HTML5 编程和 Angular 的新手。我该如何解决这个问题?
Index.aspx 是
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html data-ng-app="myApp">
<head runat="server">
<meta name="viewport" content="width=device-width"/>
<title>Index</title>
<link rel="stylesheet" type="text/css" href="/Content/dx.common.css"/>
<link rel="stylesheet" type="text/css" href="/Content/dx.light.css"/>
<script src="/Scripts/jquery-2.1.4.min.js"></script>
<script src="/Scripts/angular.js"></script>
<script src="/Scripts/angular-sanitize.js"></script>
<script src="/Scripts/jquery.globalize/globalize.js"></script>
<script src="/Scripts/dx.webappjs.js"></script>
<script src="/MyJS/script_Angular.js"></script>
</head>
<body>
<div ng-controller="demoController">
<div dx-tree-view="{
dataSource: treeViewData,
dataStructure: 'plain'
}">
</div>
</div>
</body>
</html>
并且script_Angular是
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
$scope.treeViewData = dataArray;
});
var dataArray = [
{
id: 1,
text: "Animals",
items: [
{
id: 2,
text: "Cat",
items: [
{ id: 5, text: "Abyssinian" },
{ id: 6, text: "Aegean cat" },
{ id: 7, text: "Australian Mist" }
]
},
{
id: 3,
text: "Dog",
items: [
{ id: 8, text: "Affenpinscher" },
{ id: 9, text: "Afghan Hound" },
{ id: 10, text: "Airedale Terrier" },
{ id: 11, text: "Akita Inu" }
]
},
{
id: 4,
text: "Cow"
}
]
},
{
id: 12,
parentId: 0,
text: "Birds",
items: [
{ id: 13, text: "Akekee" },
{ id: 14, text: "Arizona Woodpecker" },
{ id: 15, text: "Black-chinned Sparrow" }
]
}
];
你不应该设置选项
dataStructure: 'plain'
你的情况是 hierarchical
删除 dataStructure 选项应该有所帮助
文档是here
我有一个包含以下内容的 MVC5 项目 Index.aspx 当我 运行 VS2013 中的项目时,我只能看到树的顶部分支,没有明显的方法来展开它们。
Resharper 表明我的参考资料没问题。
我是 HTML5 编程和 Angular 的新手。我该如何解决这个问题?
Index.aspx 是
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html>
<html data-ng-app="myApp">
<head runat="server">
<meta name="viewport" content="width=device-width"/>
<title>Index</title>
<link rel="stylesheet" type="text/css" href="/Content/dx.common.css"/>
<link rel="stylesheet" type="text/css" href="/Content/dx.light.css"/>
<script src="/Scripts/jquery-2.1.4.min.js"></script>
<script src="/Scripts/angular.js"></script>
<script src="/Scripts/angular-sanitize.js"></script>
<script src="/Scripts/jquery.globalize/globalize.js"></script>
<script src="/Scripts/dx.webappjs.js"></script>
<script src="/MyJS/script_Angular.js"></script>
</head>
<body>
<div ng-controller="demoController">
<div dx-tree-view="{
dataSource: treeViewData,
dataStructure: 'plain'
}">
</div>
</div>
</body>
</html>
并且script_Angular是
var myApp = angular.module('myApp', ['dx']);
myApp.controller("demoController", function ($scope) {
$scope.treeViewData = dataArray;
});
var dataArray = [
{
id: 1,
text: "Animals",
items: [
{
id: 2,
text: "Cat",
items: [
{ id: 5, text: "Abyssinian" },
{ id: 6, text: "Aegean cat" },
{ id: 7, text: "Australian Mist" }
]
},
{
id: 3,
text: "Dog",
items: [
{ id: 8, text: "Affenpinscher" },
{ id: 9, text: "Afghan Hound" },
{ id: 10, text: "Airedale Terrier" },
{ id: 11, text: "Akita Inu" }
]
},
{
id: 4,
text: "Cow"
}
]
},
{
id: 12,
parentId: 0,
text: "Birds",
items: [
{ id: 13, text: "Akekee" },
{ id: 14, text: "Arizona Woodpecker" },
{ id: 15, text: "Black-chinned Sparrow" }
]
}
];
你不应该设置选项
dataStructure: 'plain'
你的情况是 hierarchical
删除 dataStructure 选项应该有所帮助
文档是here