1. var provinceStore = Ext.create('Ext.data.Store', {
  2. fields: ['id', 'name'],
  3. proxy: {
  4. type: 'ajax',
  5. url: '/data/CommonHandlers/ComboBoxHandler.ashx?action=province',
  6. reader: {
  7. type: 'json',
  8. root: 'items'
  9. }
  10. }
  11. });
  12.  
  13. var cityStore = Ext.create('Ext.data.Store', {
  14. fields: ['id', 'name'],
  15. proxy: {
  16. type: 'ajax',
  17. url: '/data/CommonHandlers/ComboBoxHandler.ashx',
  18. reader: {
  19. type: 'json',
  20. root: 'items'
  21. }
  22. }
  23. });
  24.  
  25. var districtStore = Ext.create('Ext.data.Store', {
  26. fields: ['id', 'name'],
  27. proxy: {
  28. type: 'ajax',
  29. url: '/data/CommonHandlers/ComboBoxHandler.ashx',
  30. reader: {
  31. type: 'json',
  32. root: 'items'
  33. }
  34. }
  35. });
  36.  
  37. {
  38. fieldLabel: '所属地区',
  39. labelWidth: 60,
  40. xtype: 'fieldcontainer',
  41. combineErrors: true,
  42. defaultType: 'textfield',
  43. defaults: {
  44. hideLabel: 'true'
  45. },
  46. layout: 'hbox',
  47. flex: 1,
  48. items: [{
  49. emptyText: '请选择省份...',
  50. flex: 3,
  51. xtype: 'combobox',
  52. name: 'Provinces',
  53. id: 'Provinces',
  54. hiddenName: 'name',
  55. store: provinceStore,
  56. selectOnFocus: true,
  57. valueField: 'id',
  58. displayField: 'name',
  59. queryMode: 'remote',
  60. editable: false,
  61. listeners: {
  62. select: function (Combox, record, index) {//联动效果
  63. Ext.getCmp('Provinces_id').setValue(this.value);
  64. var city = Ext.getCmp('City');
  65. city.clearValue();
  66. city.store.removeAll();
  67. cityStore.load({
  68. params: {
  69. action: 'city', parentid: this.value
  70. }
  71. });
  72. }
  73. }
  74. }, {
  75. emptyText: '请选择城市...',
  76. flex: 3,
  77. editable: false,
  78. selectOnFocus: true,
  79. xtype: 'combobox',
  80. id: 'City',
  81. name: 'City',
  82. margins: '0 0 0 6',
  83. valueField: 'id',
  84. displayField: 'name',
  85. store: cityStore,
  86. queryMode: 'local',
  87. listeners: {
  88. select: function (Combox, record, index) {//联动效果
  89. Ext.getCmp('City_id').setValue(this.value);
  90. var district = Ext.getCmp('District');
  91. district.clearValue();
  92. district.store.removeAll();
  93. districtStore.load({
  94. params: {
  95. action: 'city', parentid: this.value
  96. }
  97. });
  98. }
  99. }
  100. }, {
  101. emptyText: '请选择地区...',
  102. flex: 3,
  103. editable: false,
  104. selectOnFocus: true,
  105. xtype: 'combobox',
  106. id: 'District',
  107. name: 'District',
  108. margins: '0 0 0 6',
  109. valueField: 'id',
  110. displayField: 'name',
  111. store: districtStore,
  112. queryMode: 'local',
  113. listeners: {
  114. select: function (Combox, record, index) {//联动效果
  115. Ext.getCmp('District_id').setValue(this.value);
  116. }
  117. }
  118. }]
  119. }
  120.  
  121. 默认选择
  122. provinceStore.load();
  123. provinceStore.on("load", function () {
  124. Ext.getCmp('Provinces').select(provinceStore.getAt(9));//江苏省
  125. }, provinceStore, true);
  126. cityStore.load({
  127. params: {
  128. action: 'city', parentid: 10
  129. }
  130. });
  131. cityStore.on("load", function () {
  132. Ext.getCmp('City').select(cityStore.getAt(2));//徐州市
  133. }, cityStore, true);
  134. districtStore.load({
  135. params: {
  136. action: 'city', parentid: 110//区县
  137. }
  138. });

EXT 省市三级联动及默认选择的更多相关文章

  1. JS实现年月日三级联动+省市区三级联动+国家省市三级联动

    开篇随笔:最近项目需要用到关于年月日三级联动以及省市区三级联动下拉选择的功能,于是乎网上搜了一些做法,觉得有一些只是给出了小的案例或者只有单纯的js还不完整,却很难找到详细的具体数据(baidu搜索都 ...

  2. 利用select实现年月日三级联动的日期选择效果

    × 目录 [1]演示 [2]规划 [3]结构生成[4]算法处理 前面的话 关于select控件,可能年月日三级联动的日期选择效果是最常见的应用了.本文是选择框脚本的实践,下面将对日期选择效果进行详细介 ...

  3. [moka同学笔记]Yii下国家省市三级联动

    第一次做省市三级联动时候遇到了坑,感觉还是自己太菜.头疼了很久研究了很久,最后终于发现了问题.大致总结一下思路 在控制器中实例化model,然后在视图中渲染所有国家,当选取国家时候,ajax通过 id ...

  4. 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317         这个功能 ...

  5. Webform——中国省市三级联动以及IsPostBack

    首先要明白Webform的运行顺序,当开始启动时候,首先执行的是Page_Load事件, 当点击任意按钮后,每次点击都要先执行一遍Page_Load(在这里Page_Load里面的事件是给数据控件加载 ...

  6. Vue 国家省市三级联动

    在网上查阅一下,基本上是省市区三级联动,国家省市的就只能自己动手了. 样式就根据自己的需要去调整了. JSON数组太长,就折叠放在了后面. 效果图: <!DOCTYPE html> < ...

  7. asp.net MVC4——省市三级联动

    controller: public ActionResult GetCity(string id) { AreaService _areaSvc = new AreaService(); List& ...

  8. JS(JQuery) 省市区三级联动下拉选择

    引入 area.js /* * 全国三级城市联动 js版 */ function Dsy(){ this.Items = {}; } Dsy.prototype.add = function(id,i ...

  9. Yii2中省市三级联动(栏目联动)

    先从表的设计开始: 表的结构: CREATE TABLE `global_region` ( `region_id` smallint(5) unsigned NOT NULL AUTO_INCREM ...

随机推荐

  1. 【BZOJ】2719 银河之星

    可以将棋子分为9种类型.且可以通过合并使得两个不同种类棋子转换为另一种棋子(不过要注意棋盘大小,有的时候硬要合并会到棋盘外面,可以先把棋盘全部转换,然后枚举每一个棋子的转换).然后把状态压成一个十位的 ...

  2. 【Android】Android清除本地数据缓存代码

    最近做软件的时候,遇到了缓存的问题,在网上看到了这个文章,感觉不错.分享给大家看看 文章出处:http://www.cnblogs.com/rayray/p/3413673.html /* * 文 件 ...

  3. Jenkins快速上手

    一.Jenkins下载安装 1.到官网下载jenkins.war包:http://jenkins-ci.org/ 2.安装方法有两种: a) 把下载下来的jenkins.war包放到文件夹下,如C:\ ...

  4. [vijos P1083] 小白逛公园

    不知怎地竟有种错觉此题最近做过= =目测是类似的?那道题貌似是纯动归? 本来今晚想做两道题的,一道是本题,一道是P1653疯狂的方格取数或NOI08 Employee,看看现在的时间目测这个目标又达不 ...

  5. MapReducer程序调试技巧

    写过程序分布式代码的人都知道,分布式的程序是比较难以调试的,但是也不是不可以调试,对于Hadoop分布式集群来说,在其上面运行的是mapreduce程序,因此,有时候写好了mapreduce程序之后, ...

  6. JAVA ,Map接口 ,迭代器Iterator

    1.    Map 接口概述 java.util.Map 接口描述了映射结构, Map 接口允许以键集.值集合或键 - 值映射关系集的形式查看某个映射的内容. Java 自带了各种 Map 类. 这些 ...

  7. OrCAD搭建Access数据库

    刚进入到一个小公司,接到的第一个电路设计的案子是从零开始的,辛苦就不说,关键是这么不严谨,容易出错,于是乎,问题来了,能否从零开始着手建立个类似于以前公司的数据库,管理原理图封装,PCB封装及规格书! ...

  8. Libgdx 开发指南——目录

    本系列文档选译自libgdx github项目 wiki : https://github.com/libgdx/libgdx/wiki 由于关于Libgdx的中文文档非常稀缺,因此在这里对官方Wik ...

  9. Ubuntu软件中心打不开,Encountered a section with no Package: header错误之解决

    sudo rm /var/lib/apt/lists/* -vf sudo apt-get update

  10. 图片过大导致OOM

    原文:http://www.codeceo.com/article/android-load-image-oom.html 一.分析 在加载图片过程中出现的OOM的几种情况: 1. 加载的图片过大 2 ...