【发布时间】:2013-07-31 20:09:29
【问题描述】:
后面的代码:
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptBlock(GetType(), "MyKey", "CreateNotificationTree(" + UserId + ")", true);
}
.js 文件:
function CreateNotificationTree(UserId)
{
var data = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "../api/notifications/byuserid/" + UserId,
contentType: "application/json"
}
},
schema: {
model: {
children: "notifications"
}
}
});
$("#treeview").kendoTreeView({
dataSource: data,
loadOnDemand: true,
checkboxes: {
checkChildren: true
},
dataTextField: ["notificationType", "NotificationDesc"]
});
}
标记(我需要这个吗?):
<script type="text/javascript">
$(document).ready(CreateNotificationTree(UserId));
</script>
这不起作用。树视图未加载到页面上。
【问题讨论】:
-
这里提到的副本对我没有一点帮助。
-
尝试从 aspx 页面中删除您的函数调用。因为在您的代码隐藏中,您已经在 page_load 事件中调用了该函数。
标签: c# javascript