Ext中grid實現模糊查詢 – JAVA編程語言程序開發技術文章

在action中find_all方法中,加入以下代碼:

[java] 
//根據輸入的查詢字模糊查詢 
        if(searchWord!=null && !"".equals(searchWord)){ 
            if(condition ==null){ 
                condition = new Condition(); 
            } 
            ConditionRule cr1 = new ConditionRule("sysName",searchWord,Condition.Mode.CONTAIN,Condition.Type.AND); 
            ConditionRule cr2 = new ConditionRule("projectName",searchWord,Condition.Mode.CONTAIN,Condition.Type.OR); 
            ConditionRuleGroup crg = new ConditionRuleGroup(); 
            crg.addRule(cr1,cr2); 
            condition.addRuleGroup(crg); 
        } 

若想實現時間排序,按照時間最近的在前面:
Ordinal ordinal= OrdinalUtil.createOrdinal(this,new String []{"creatorDate:DESC"},null);

發佈留言