function search_node(){
var search_value = $("#search_sel").find("option:selected").text();
var index = $("#search_sel").find("option:selected").val()
var search_path = list_file[index];
console.log("search tree ...")
var initSelectableTree = function() {
return $('#left_con').treeview({
data: data_1,
multiSelect: false,
onNodeSelected: function(event, node) {
console.log(node.text+"was selected.")
if(search_path){
arrange_data_ajax(search_path);
}
//$('#selectable-output').prepend('<p>' + node.text + ' was selected</p>');
},
onNodeUnselected: function (event, node) {
// $('#selectable-output').prepend('<p>' + node.text + ' was unselected</p>');
}
});
};
var $selectableTree = initSelectableTree();
var findSelectableNodes = function() {
return $selectableTree.treeview('search', [ search_value, { ignoreCase: false, exactMatch: true } ]);
};
var selectableNodes = findSelectableNodes();
/* $("#search_sel").on('keyup', function (e) {
selectableNodes = findSelectableNodes();
// $('.select-node').prop('disabled', !(selectableNodes.length >= 1));
}); */
var nodes_index=0;
for (var k=0;k<selectableNodes.length;k++){
console.log("selectableNodes:"+selectableNodes[k].file_path);
if(selectableNodes[k].file_path == search_path){
console.log("K:"+k);
nodes_index = k;
break;
}
}
$('#btn_go').on('click', function (e) {
$selectableTree.treeview('selectNode', [ selectableNodes[k], { silent: false }]);
});
console.log("search_path:"+search_path);
/* $('#btn_go').on('click', function (e) {
$selectableTree.treeview('selectNode', [ selectableNodes[0], { silent: false }]);
}); */
}
$("#btn_go").click(function(){
search_node();
})
/*============================================================================*/
for(int i=0;i<TreeView1.Nodes.Count;i++) {
if(TreeView1.Nodes[i]==TextBox1.Text){
string index1=TreeView1.Nodes[i].GetNodeIndex();//取得index
TreeView1.SelectedNodeIndex=index1;
}
}
function searchTree(element, matchingTitle){
if(element.title == matchingTitle){
return element;
}else if (element.children != null){
var i;
var result = null;
for(i=0; result == null && i < element.children.length; i++){
result = searchTree(element.children[i], matchingTitle);
}
return result;
}
return null;
}
function search_tree(treeID,tree_data,search_value){
console.log("using Search function!");
var searchedTree = treeID;
var $searchableTree = $(treeID).treeview({
data: tree_data
});
var search = function() {
var pattern = search_value;
var options = {
ignoreCase: true,
exactMatch: true,
revealResults: true //倒数匹配
};
var results = $searchableTree.treeview('search', [pattern, options]);
console.log("results length:"+results.length+results.text);
}
if(searchedTree=="#treeview1"){
$('#btn_gol').on('click', search);
console.log("click left go!");
}else{
$('#btn_gor').on('click', search);
console.log("click right go!");
}
}
search Tree view node
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 思路:对比已有的node,比它小的或者相等的放在左子树,比它大的放在右子树。
- 原题 给定一棵二叉查找树和一个新的树节点,将节点插入到树中。你需要保证该树仍然是一棵二叉查找树。 给出如下一棵二叉...
- 解題思路 : 直接先檢查 root 是否為 nullptr 如果是則回傳 node 不是的話則比較 node 跟 ...
- 解題思路 : 首先要先找到想移除的點 利用比較 target 跟當前檢查的 node value 比較 較大就往右...