gpt4 book ai didi

css - 如何将以下 CSS 仅应用于 Kendo Treeview 的父节点?

转载 作者:行者123 更新时间:2023-11-28 18:13:36 25 4
gpt4 key购买 nike

我有这个 CSS 类:

.relationshipsTree 
{
display: inline;
font-size: 10pt;
text-decoration: none;
/*cursor: hand;*/
overflow: hidden;
overflow-x: hidden;
overflow-y: hidden;
filter: none;
font-weight: bold;
color: green;
background-color: transparent;
}

我想在这个 Kendo Tree View 的父节点上使用它:

<div id="relationshipsTree"></div>

我该怎么做?

编辑 -

这是我用来创建树的 .js 文件。我补充说:

$('#relationshipsTree').parent().addClass('relationshipsTree');

然而,根据此处的回答,它仍然无法正常工作。

整个文件:

function CreateRelationshipsTree()
{
var primaryContactId = 671;
var personOrCompany = 'C';
var rootMemberId = 0;

var data = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "../api/relationships?primaryContactId=" + primaryContactId + "&personOrCompany=" + personOrCompany + "&rootMemberId=" + rootMemberId,
contentType: "application/json"
}
},
schema: {
model: {
hasChildren: "hasChildren",
children: "Items"
}
}
});

$("#relationshipsTree").kendoTreeView({
dataSource: data,
loadOnDemand: true,
dataUrlField: "LinksTo",
dataTextField: ["Name", "Name"],
select: treeviewSelect
});

function treeviewSelect(e) {
var node = this.dataItem(e.node);
window.open(node.NotificationLink, "_self");
}

$('#relationshipsTree').parent().addClass('relationshipsTree');
}

function RefreshProjectTree() {
var treeView = $("#relationshipsTree").data("kendoTreeView");
treeView.dataSource.read();
}

最佳答案

已更新

我发现我误解了你的问题。我认为您想在 Treeview 中选择父节点时选择 DOM 父元素。这是我更新的答案。

稍微简化您的处理程序:

function treeviewSelect(e) {
$('#relationshipsTree div').removeClass('relationshipsTree');
$(e.node).parents('li').first().children('div').addClass('relationshipsTree');
var node = this.dataItem(e.node);
window.open(node.NotificationLink, "_self");

}

演示已更新here

关于css - 如何将以下 CSS 仅应用于 Kendo Treeview 的父节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18258349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com