Reputation: 9960
I have this CSS class:
.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;
}
And I want to use it on the parent nodes of this Kendo Tree View:
<div id="relationshipsTree"></div>
How do I go about doing this?
EDIT -
This is the .js file I'm using to create the tree. I added:
$('#relationshipsTree').parent().addClass('relationshipsTree');
Based on an answer here, however, it is still not working.
Whole file:
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();
}
Upvotes: 1
Views: 2496
Reputation: 8415
I found that I have misunderstood your question. I think you want to select the DOM parent element while you want to select the parent node in the tree view. This is my updated answer.
Midify your handler a bit:
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");
}
A demo updated here
Upvotes: 1
Reputation: 768
YOu can use jquery to target the parent of an element.
$('#youselector').parent().css({
display:'inline',
font-size:'10pt',
text-decoration:'none',
overflow:'hidden',
overflow-x:'hidden',
overflow-y:'hidden',
filter:'none',
font-weight:'bold',
color:'green',
background-color:'transparent',
});
Upvotes: 0