Èý¡¢¡¾ExtJS4ѧϰ±Ê¼Ç¡¿AjaxÔ¶³Ì·ÃÎÊÊý¾ÝԴʾÀý
Ç°¶ËÒ³Ã棺
<HTML> <HEAD> <TITLE>Ô¶³ÌÊý¾ÝÔ´µÄ×éºÏ¿òʾÀý</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link type="text/css" href="extjs4/resources/css/ext-all.css" /> <script type="text/javascript" src="extjs4/bootstrap.js"></script> <script type="text/javascript" src="extjs4/ext-lang-zh_CN.js"></script> <script type="text/javascript"> Ext.onReady(function(){ //´´½¨Êý¾ÝÄ£ÐÍ Ext.regModel('BookInfo', { fields: [{name: 'bookName'}] }); //¶¨Òå×éºÏ¿òÖÐÏÔʾµÄÊý¾ÝÔ´ var bookStore = Ext.create('Ext.data.Store',{ model : 'BookInfo', proxy: { type: 'ajax',//Ext.data.AjaxProxy url : 'bookSearchServer.jsp', reader: new Ext.data.ArrayReader({model : 'BookInfo'}) } }); //´´½¨±íµ¥ Ext.create('Ext.form.Panel',{ title:'Ext.form.field.ComboBoxÔ¶³ÌÊý¾ÝԴʾÀý', frame : true, height:100, width:270, renderTo: Ext.getBody(), bodyPadding: 5, defaults:{//ͳһÉèÖÃ±íµ¥×Ö¶ÎĬÈÏÊôÐÔ labelSeparator :'£º',//·Ö¸ô·û labelWidth : 70,//±êÇ©¿í¶È width : 200,//×ֶοí¶È labelAlign : 'left'//±êÇ©¶ÔÆ뷽ʽ }, items:[{ xtype : 'combo', fieldLabel:'Êé¼®Áбí', listConfig : { loadingText : 'ÕýÔÚ¼ÓÔØÊé¼®ÐÅÏ¢',//¼ÓÔØÊý¾ÝʱÏÔʾµÄÌáʾÐÅÏ¢ emptyText : 'δÕÒµ½Æ¥ÅäÖµ',//µ±Öµ²»ÔÚÁбíÊǵÄÌáʾÐÅÏ¢ maxHeight : 100//ÉèÖÃÏÂÀÁбíµÄ×î´ó¸ß¶ÈΪ60ÏñËØ }, allQuery:'allbook',//²éѯȫ²¿ÐÅÏ¢µÄ²éѯ×Ö·û´® minChars : 3,//ÏÂÀÁбí¿ò×Ô¶¯Ñ¡ÔñÇ°Óû§ÐèÒªÊäÈëµÄ×îС×Ö·ûÊýÁ¿ queryDelay : 300,//²éѯÑÓ³Ùʱ¼ä queryParam : 'searchbook',//²éѯµÄÃû×Ö triggerAction: 'all',//µ¥»÷´¥·¢°´Å¥ÏÔʾȫ²¿Êý¾Ý store : bookStore,//ÉèÖÃÊý¾ÝÔ´ displayField:'bookName',//¶¨ÒåÒªÏÔʾµÄ×ֶΠvalueField:'bookName',//¶¨ÒåÖµ×ֶΠqueryMode: 'remote'//Ô¶³Ìģʽ }] }); }); </script> </HEAD> <BODY> </BODY> </HTML>JSP´úÂ룺
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <% String bookName = request.getParameter("searchbook"); String jav = "['java±à³Ì˼Ïë'],['javaÈëÃÅ'],['javascript³ÌÐòÉè¼Æ']"; String cpp = "['c++±à³Ì˼Ïë'],['c++ÈëÃÅ'],['c++³ÌÐòÉè¼Æ']"; String php = "['php³ÌÐòÉè¼Æ'],['phpÈëÃÅ'],['php´ÓÈëÃŵ½¾«Í¨']"; String books = ""; if(bookName.equals("allbook")){ books = "["+jav+","+cpp+","+php+"]"; response.getWriter().write(books); return; }else{ bookName = bookName.substring(0,3);//È¡²éѯ×Ö·û´®µÄÇ°3¸ö×Ö·û System.out.println(bookName); if(bookName.equals("jav")){ books = "["+jav+"]"; }else if(bookName.equals("c++")){ books = "["+cpp+"]"; }else if(bookName.equals("php")){ books = "["+php+"]"; }else{ books = "[['ûÓÐÊý¾Ý']]"; } response.getWriter().write(books); } %> ¸½£ºExtJs4ѧϰ±Ê¼ÇĿ¼ÔÎijö´¦£ºhnhnhnhnhnµÄ²©¿Í
Äã¿ÉÒÔ¼ÌÐøÔĶÁÏà¹Ø¡¾ExtJs4 , ExtJs4ѧϰ , Ç°¶Ë¼¼Êõ¡¿µÄÎÄÕ¡£
¡¡