Extcombox dynamic search

Source: Internet
Author: User
Javacode: [html] packagecompaicbbsaction; importjavaioOutputStreamWriter; importjavasjavasqlpreparedstatement; importjavasqlResultSet; importjavasqlStatement; importjava code: [html] package com. paic. bbs. action; import java. io. outputStreamWriter; import java. SQL. preparedStatement; import java. SQL. resultSet; import java. SQL. statement; import java. util. arrayList; import java. util. list; import javax. servlet. http. httpServletRequest; import javax. servlet. http. httpServletResponse; import org. springframework. web. servlet. modelAndView; import org. springframework. web. servlet. mvc. abstractController; import com. paic. bbs. DAO. DBUtils; import com. paic. bbs. DTO. loginIsToCollect; import com. paic. bbs. DTO. schemaidBean; public class SchemaidAction extends AbstractController {public ModelAndView handleRequestInternal (HttpServletRequest request, HttpServletResponse response) throws Exception {String SQL = "select * from t_schemaidinfo"; int total = 0; preparedStatement ps1 = DBUtils. getConnection (). prepareStatement (SQL); ResultSet rs1 = ps1.executeQuery (); List List1 = new ArrayList (); While (rs1.next () {SchemaidBean sch = new SchemaidBean (); sch. setID (rs1.getInt (1); sch. setSCHEMAID (rs1.getString (2); sch. setDescribe (rs1.getString (3); list1.add (sch); total ++;} StringBuffer sb = new StringBuffer (); sb = sb. append ("{'root': ["); for (int I = 0; I <list1.size (); I ++) {sb. append ("{'schemaid': '" + list1.get (I ). getSCHEMAID () + "', 'describe':'" + list1.get (I ). getDescribe () + "'}"); if (I! = (List1.size ()-1) sb. append (",");} sb. append ("]}"); System. out. println (sb. toString (); response. setCharacterEncoding ("UTF-8"); response. getWriter (). print (sb. toString (); response. getWriter (). close (); return null ;}} js code: combox code [html] var combobox = new Ext. form. comboBox ({id: 'pid ', fieldLabel: 'indicator name', store: new Ext. data. store ({proxy: new Ext. data. httpProxy ({url: '/KITWEB/SchemaidAction. Do '// Request Path}), reader: new Ext. data. jsonReader ({root: 'root', totalProperty: 'Total'}, [{name: 'schemaid'}, {name: 'describe'}]), autoLoad: true}), displayField: 'describe', valueField: 'scheimaid', hiddenName: 'scheimaid', // triggerAction: 'all', emptyText: 'select... ', allowBlank: false, blankText:' select SCHEMAID, typeAhead: true, minChars: 1, lazyInit: false, mode: 'remote', listeners: {'be Forequery': function (e) {var combo = e. combo; if (! E. forceAll) {var input = e. query; // The retrieved regular var regExp = new RegExp (". * "+ input + ". * "); // execute the search combo. store. filterBy (function (record, id) {// obtain the project name value of each record var text = record. get (combo. displayField); return regExp. test (text) ;}); combo. expand (); return false ;}}, 'click': function () {this. expand ();}}});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.