marcelduran/yslow

Select a node by attribute

themhz opened this issue · 0 comments

Hello, I am feeding the treeview with the object displayed below and it works perfectly well. However I need to set the SubNode 2 as selected node, but it only works if I specify the index of the array like that
$('#tree').treeview('selectNode', [ 1, { silent: true } ]);

Is there a way to select the node by its Id? or any other attribute?

something like $('#tree').treeview('selectNode', [ {id:2}, { silent: true } ]);

[{
	"id":"1",
	"parent_id":"0",
	"title":Node 1,
	"active":"1",
	"account_id":"1",
	"regdate":null,
	"text":"Node 1",
	"nodes":[
				{"id":"2",
				 "parent_id":"1",
				 "title":"SubNode 2",
				 "active":"1",
				 "account_id":"1",
				 "regdate":null,
				 "text":"SubNode 2"},
				{"id":"3",
				 "parent_id":"1",
				 "title":"SubNode 3",
				 "active":"1",
				 "account_id":"1",
				 "regdate":null,
				 "text":"SubNode 3"},
				{"id":"6",
				"parent_id":"1",
				"title":"SubNode 6",
				"active":"1",
				"account_id":"1",
				"regdate":"2017-05-01 01:53:25",
				"text":"SubNode 6"}
			]
}
,{"id":"5",
  "parent_id":"0",
  "title":"Node 5",
  "active":"1",
  "account_id":"1",
  "regdate":"2017-05-01 01:51:56",
  "text":"Node 5"}
 
 ]