Extjs 树支持模糊查询定位
来源:互联网 发布:湘西蛊毒 知乎 编辑:程序博客网 时间:2024/06/01 10:43
var rightTree = new Ext.tree.TreePanel({
region : 'center',
split : true,
animate:true, //展开,收缩动画
xtype : 'treepanel',
width : 240,
autoScroll : true,
id : 'tree',
// collapsible : true,
title : '区域列表',
loader : new Ext.tree.TreeLoader( {
dataUrl : ctx + '/hbms/installGroupGuard/installGroupGuard.action?method=queryParam&imUnitName='+encodeURI(encodeURI(r.get('imUnitName')))
+'&imGroupName='+encodeURI(encodeURI(r.get('imGroupName')))
}),
root : new Ext.tree.AsyncTreeNode( {
id : "SZ",
text : "深圳",
leaf : false
}),
tbar:[{
icon: ctx + "/images/xtree/Tplus.png",
tooltip: '展开',
handler: function(){ rightTree.expandAll(); },
scope: this
}, '-', {
icon: ctx + "/images/xtree/Tminus.png",
tooltip: '收缩',
handler: function(){ rightTree.collapseAll(); },
scope: this
}
/* , new Ext.form.TextField({
width: 150,
emptyText:'快速检索',
enableKeyEvents: true,//给输入框绑定keyup事件,需要加上enableKeyEvents:true才能让extjs的textfield代理鼠标事件
listeners:{
keyup:function(node, event) {
findByKeyWordFiler(node, event);
},
scope: this
}
})*/
],
listeners : {
checkchange : function(node, checked) {
if(checked){
treeCheckTrue(node);
}else{
treeCheckFalse(node);
}
var flag = false;
for(var i=0;i<params.length;i++){
if(params[i].commId == node.id){
params[i].commName = node.text;
params[i].checked = checked;
flag = true;
break;
}
}
if(!flag){
var param = {};
param.commId = node.id;
param.commName = node.text;
param.checked = checked;
params.push(param);
}
}
}
});
// rightTree.expandAll();
var timeOutId = null;
var filterTreeFiled = new Ext.form.TextField({
width:115,
emptyText:'快速检索',
enableKeyEvents: true
});
var tbar = rightTree.getTopToolbar();
tbar.add(filterTreeFiled);tbar.doLayout();
var selectNode = function(node) {
node.ensureVisible();
node.select();
// Ext.tree.MultiSelectionModel.select();
node.fireEvent('click', node);
}
function onExpandPathComplete(bSuccess, oLastNode) {
if (!bSuccess)
return;
// focus 节点,并选中节点!
selectNode(oLastNode);
}
var findByKeyWordPath = function(node, event) {
clearTimeout(timeOutId);
timeOutId = setTimeout(function() {
var text = node.getValue().trim();
lastSerach=text;
// 采用ajax获得需要展开的路径
if (text != "") {
Ext.Ajax.request({
params : {
keyWord : text
},
url :ctx + '/hbms/installGroupGuard/installGroupGuard.action?method=searchNode',
method : 'POST',
async : false,
success : function(response, opts) {
var obj = Ext.decode(response.responseText);
console.log(obj);
if(obj.success){
var length = obj.list.length;
rightTree.root.reload();
for(var i=0;i<length;i++){
var path = obj.list[i].path;
rightTree.expandPath("/SZ"+path,'id',onExpandPathComplete);
}
}
},
failure : function(response, opts) {
Ext.Msg.alert("错误提示", "请求失败,请与管理员联系。").setIcon(Ext.MessageBox.ERROR);
}
});
} else {
}
}, 500);
}
filterTreeFiled.on("keyup", function(node, event) {
findByKeyWordPath(node, event);
});
/**
*checkTree全选
*/
var treeCheckTrue = function(node)
{
node.eachChild(function (child) {
child.getUI().toggleCheck(true);
child.attributes.checked = true;
treeCheckTrue(child);
});}
/**
* checkTree取消
*/
var treeCheckFalse = function(node)
{
node.eachChild(function (child) {
child.getUI().toggleCheck(false);
child.attributes.checked = false;
treeCheckTrue(child);
region : 'center',
split : true,
animate:true, //展开,收缩动画
xtype : 'treepanel',
width : 240,
autoScroll : true,
id : 'tree',
// collapsible : true,
title : '区域列表',
loader : new Ext.tree.TreeLoader( {
dataUrl : ctx + '/hbms/installGroupGuard/installGroupGuard.action?method=queryParam&imUnitName='+encodeURI(encodeURI(r.get('imUnitName')))
+'&imGroupName='+encodeURI(encodeURI(r.get('imGroupName')))
}),
root : new Ext.tree.AsyncTreeNode( {
id : "SZ",
text : "深圳",
leaf : false
}),
tbar:[{
icon: ctx + "/images/xtree/Tplus.png",
tooltip: '展开',
handler: function(){ rightTree.expandAll(); },
scope: this
}, '-', {
icon: ctx + "/images/xtree/Tminus.png",
tooltip: '收缩',
handler: function(){ rightTree.collapseAll(); },
scope: this
}
/* , new Ext.form.TextField({
width: 150,
emptyText:'快速检索',
enableKeyEvents: true,//给输入框绑定keyup事件,需要加上enableKeyEvents:true才能让extjs的textfield代理鼠标事件
listeners:{
keyup:function(node, event) {
findByKeyWordFiler(node, event);
},
scope: this
}
})*/
],
listeners : {
checkchange : function(node, checked) {
if(checked){
treeCheckTrue(node);
}else{
treeCheckFalse(node);
}
var flag = false;
for(var i=0;i<params.length;i++){
if(params[i].commId == node.id){
params[i].commName = node.text;
params[i].checked = checked;
flag = true;
break;
}
}
if(!flag){
var param = {};
param.commId = node.id;
param.commName = node.text;
param.checked = checked;
params.push(param);
}
}
}
});
// rightTree.expandAll();
var timeOutId = null;
var filterTreeFiled = new Ext.form.TextField({
width:115,
emptyText:'快速检索',
enableKeyEvents: true
});
var tbar = rightTree.getTopToolbar();
tbar.add(filterTreeFiled);tbar.doLayout();
var selectNode = function(node) {
node.ensureVisible();
node.select();
// Ext.tree.MultiSelectionModel.select();
node.fireEvent('click', node);
}
function onExpandPathComplete(bSuccess, oLastNode) {
if (!bSuccess)
return;
// focus 节点,并选中节点!
selectNode(oLastNode);
}
var findByKeyWordPath = function(node, event) {
clearTimeout(timeOutId);
timeOutId = setTimeout(function() {
var text = node.getValue().trim();
lastSerach=text;
// 采用ajax获得需要展开的路径
if (text != "") {
Ext.Ajax.request({
params : {
keyWord : text
},
url :ctx + '/hbms/installGroupGuard/installGroupGuard.action?method=searchNode',
method : 'POST',
async : false,
success : function(response, opts) {
var obj = Ext.decode(response.responseText);
console.log(obj);
if(obj.success){
var length = obj.list.length;
rightTree.root.reload();
for(var i=0;i<length;i++){
var path = obj.list[i].path;
rightTree.expandPath("/SZ"+path,'id',onExpandPathComplete);
}
}
},
failure : function(response, opts) {
Ext.Msg.alert("错误提示", "请求失败,请与管理员联系。").setIcon(Ext.MessageBox.ERROR);
}
});
} else {
}
}, 500);
}
filterTreeFiled.on("keyup", function(node, event) {
findByKeyWordPath(node, event);
});
/**
*checkTree全选
*/
var treeCheckTrue = function(node)
{
node.eachChild(function (child) {
child.getUI().toggleCheck(true);
child.attributes.checked = true;
treeCheckTrue(child);
});}
/**
* checkTree取消
*/
var treeCheckFalse = function(node)
{
node.eachChild(function (child) {
child.getUI().toggleCheck(false);
child.attributes.checked = false;
treeCheckTrue(child);
});}
0 0
- Extjs 树支持模糊查询定位
- ExtJs combobox支持模糊匹配
- Mysql 数据库模糊查询定位
- 下拉框 支持模糊查询
- DataView中实现模糊查询,定位
- js模糊查询 定位select 下拉框
- oracle 存储过程支持模糊查询
- Select下拉框(支持输入模糊查询)
- EasyUI支持模糊查询的Combotree
- oracle模糊查询之通配符----hihernate---支持
- 如何让我们的ExtJs combobox支持模糊匹配
- extjs + Web ADF Javascript实现属性查询、定位
- Hibernate分页的实现(支持模糊查询)
- abap如何实现支持通配符*模糊查询(support wildcard search)
- Select下拉列表类(支持输入模糊查询)
- 数据查询支持中文拼音首字母模糊检索
- Select下拉列表类(支持输入模糊查询)
- AngularJS+Bootstrap 分页功能实现,同时支持模糊查询分页
- The future of news? Virtual reality(2015年5月发布于TED)
- 贩妖记 > 第四十五章,怨气法宝
- 西安地铁标识系统分析
- window下查看端口号和进程名
- java右键菜单的添加
- Extjs 树支持模糊查询定位
- 柳青
- Python中的defer库
- Bootstrap 全局样式的简单介绍
- 用户、目录与文件类命令
- 专题四 Problem H
- 替换空格
- STL总结
- 受邀,用尽浑身解数对公司废物测试,结束,终于回归了,以后每天来点干货~AS主题