【ExtJS4学习笔记03】Ajax远程访问数据源示例

前端之家收集整理的这篇文章主要介绍了【ExtJS4学习笔记03】Ajax远程访问数据源示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

【ExtJS4学习笔记03】Ajax远程访问数据源示例

摘要【ExtJS4学习笔记03】Ajax远程访问数据源示例:远程数据源的组合框示例

三、【ExtJS4学习笔记】Ajax远程访问数据源示例

前端页面

01. <HTML>
02. HEAD>
03. TITLE>远程数据源的组合框示例</04. Metahttp-equiv="Content-Type"content"text/html; charset=utf-8"05. linkrel"stylesheet"type"text/css"href"extjs4/resources/css/ext-all.css"/>
06. script"text/javascript"src"extjs4/bootstrap.js"></script07. "extjs4/ext-lang-zh_CN.js"08. "text/javascript"09. Ext.onReady(function(){
10. //创建数据模型
11. Ext.regModel('BookInfo',{
12. fields: [{name: 'bookName'}]
13. });
14. //定义组合框中显示的数据源
15. var bookStore = Ext.create('Ext.data.Store',92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">16. model : 'BookInfo',
17. proxy: {
18. type: 'ajax',//Ext.data.AjaxProxy
19. url : 'bookSearchServer.jsp',
20. reader: new Ext.data.ArrayReader({model : 'BookInfo'})
21. }
22. });
23. //创建表单
24. Ext.create('Ext.form.Panel',{
25. title:'Ext.form.field.ComboBox远程数据源示例',92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">26. frame : true,92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">27. height:100,92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">28. width:270,92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">29. renderTo: Ext.getBody(),92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">30. bodyPadding: 5,92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">31. defaults:{//统一设置表单字段默认属性
32. labelSeparator :':',//分隔符
33. labelWidth : 70,//标签宽度
34. width : 200,//字段宽度
35. labelAlign : 'left'//标签对齐方式
36. },92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">37. items:[{
38. xtype : 'combo',92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">39. fieldLabel:'书籍列表',92)!important; margin:0px!important; border:0px!important; outline:0px!important; text-align:right!important; float:left!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:3em!important; line-height:1.2em!important; font-size:13px!important; display:block!important; background:none!important">40. listConfig : {
41. loadingText : '正在加载书籍信息',//加载数据时显示提示信息
42. emptyText : '未找到匹配值',//当值不在列表是的提示信息
43. maxHeight : 100//设置下拉列表的最大高度为60像素
44. 45. allQuery:'allbook',//查询全部信息的查询字符串
46. minChars : 3,//下拉列表框自动选择前用户需要输入的最小字符数量
47. queryDelay : 300,//查询延迟时间
48. queryParam : 'searchbook',//查询的名字
49. triggerAction: 'all',//单击触发按钮显示全部数据
50. store : bookStore,//设置数据源
51. displayField:'bookName',//定义要显示的字段
52. valueField:'bookName',//定义值字段
53. queryMode: 'remote'//远程模式
54. }]
55. 56. 57. </58. 59. BODYSTYLE"margin: 10px"60. BODY61. >

JSP代码

<%@ page language="java"contentType=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);
"jav"else"c++""PHP""[['没有数据']]"}
response.getWriter().write(books);
%>

附:ExtJs4学习笔记目录

  1. 【ExtJs4学习笔记01】基础知识
  2. 【ExtJS4学习笔记02】Form表单控件
  3. 【ExtJS4学习笔记03】Ajax远程访问数据源示例
  4. 【ExtJS4学习笔记04】uploadForm图片上传
  5. 【ExtJS4学习笔记05】Panel面板使用
  6. 【ExtJS4学习笔记06】一些小知识点
  7. 【ExtJS4学习笔记07】事件绑定
  8. 【ExtJS4学习笔记08】Template
  9. 【ExtJS4学习笔记09】数据模型
  10. 【ExtJS4学习笔记10】Grid
  11. 【ExtJS4学习笔记11】树控件

原文出处:hnhnhnhnhn的博客

你可以继续阅读相关【ExtJs4,ExtJs4学习,前端技术】的文章

声明:本文由「子任」原创编辑整理,转载请保留链接:【ExtJS4学习笔记03】Ajax远程访问数据源示例

原文链接:https://www.f2er.com/ajax/162479.html

猜你在找的Ajax相关文章