用JSP写搜索框

      dockedItems:[{
            xtype:'toolbar',
            items:[new Ext.form.TextField({
                id:'treeSearch',
                width:200,
                emptyText:'请输入关键字检索',
                listeners:{
                    'specialkey':function(field,e){
                        if(e.getKey() == Ext.EventObject.ENTER){
                            setNodes(centertree);
                        }
                    }
                }
            }),{
                icon: '${ctx}/img/query.gif',
                handler:function(){
                    setNodes(centertree);
                }
            }]
        }],
        getMatchNode:function(node,text,by,array){
            var matchNodeArray = [], me = this ;
            if(node){
                var childNodes = node.childNodes,
                    length     = childNodes.length,
                    i;
                for (i = 0; i < length; i++) {
                    var childNode = childNodes[i] ;
                    if (childNode && childNode.data[by] && childNode.data[by].toString().toLowerCase()
                        .indexOf(text.toLowerCase())>-1) {
                        if(childNode.isLeaf()){ //当前节点
                            matchNodes.push(childNode);
                        }else {
                            matchNodes.push(childNode);
                            me.getMatchNode(childNode,text,by,array);
                        }
                    }else {
                        if(childNode.isLeaf()){ //当前节点
                        }else {
                            me.getMatchNode(childNode,text,by,array);
                        }
                    }
                }

            }
        }

    });

    setNodes = function(tree){
        setNodesMsg=Ext.Msg.show({title: '操作提示 ',msg: '查询中...',icon: Ext.MessageBox.WARNING});
        var temNodes=[];
        var centerText = Ext.getCmp("treeSearch").getValue();
        if(centerText==""){
            leftTree.getStore().reload();
            setTimeout('setNodesMsg.hide()','1000');
            return;
        }
        //var view = tree.getView();
        var root = centertree.getRootNode() ;
        var array = [] ;
        //清除上一次操作记录
        for(var i=0;i")+1,value.lastIndexOf("<")));
            if(matchNodes[i].isLeaf()){
                temNodes.push(matchNodes[i].parentNode);
            }
        }
        matchNodes=[];
        //获取查询到的节点
        centertree.getMatchNode(root,centerText,'text',array) ;

        for(var i=0;i'+matchNodes[i].data['text']+'');
        }

        for(var i=0;i'
        ,
   });

   var viewport = Ext.create('Ext.Viewport',{
      layout:'border',
      items:[
         leftTree,
         centertree
      ]
   });
//获取左边unitId对应的信息列表框
    document.getElementById("mt_formListTreeFrame1").src = "${pageContext.request.contextPath} /formDefine.do?method=formListView&uuid=2360b24c-ab61-44e1-bd96-d27ff28174a3&hideButton=true";

你可能感兴趣的:(java)