打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
自己写的三级联动 extjs4.2 combobox

Ext.define("AddProblem",{
 extend:"CommonModule",
 problemStore:null,
 init:function(){
  var me = this;
  return me._createPanle();
 },
 _createPanle:function(){
  var me=this; 
  var store1  = Ext.create("Ext.data.Store", {
   fields : ['code', 'name','parentcode'],
   autoLoad : true,
   proxy : {
    reader : {
     root : 'records'
    },
    type : 'direct',
    directFn:'DirectService.listType'
   }
  });
  store1.on('beforeload',function(store,options){
   store.proxy.extraParams.后台变量 =0;
   store.proxy.extraParams.后台变量=1;
  });

  var store2  = Ext.create("Ext.data.Store", {
   fields : ['code', 'name','parentcode'],
   proxy : {
    reader : {
     root : 'records'
    },
    type : 'direct',
    directFn:'DirectService.listType'
   }
  });
  
  var store3  = Ext.create("Ext.data.Store", {
   fields : ['code', 'name','parentcode'],
   proxy : {
    reader : {
     root : 'records'
    },
    type : 'direct',
    directFn:'DirectService.listType'
   }
  });
  var addForm = Ext.create('Ext.form.Panel',{
   frame: true,
   header:false,
   margin:3,
   bodyPadding: '5 5 0',
   collapsible: true,
   width:520,
   fieldDefaults: {
    msgTarget: 'side',
    labelWidth: 60,
    margin:'0 15 0 0'
   },
   defaults:{
    margin:'10 10 0 10'
   },
   api:{
    submit:DirectService.insert
   },
   defaultType: 'textfield',
   items: [{
    xtype: 'fieldcontainer',
    layout: 'hbox',
    defaultType: 'textfield',
    items: [{
     name:'category',
     hiddenName:'category',
     width: 230,
     xtype : 'combobox',
     displayField : 'name',
     valueField : 'code',
     queryMode : 'local',
     editable:false,
     fieldLabel:'问题类别',
     allowBlank: false,
     blankText:'问题类别不能为空!',
     store : store1,
     listeners:{
      select:function(itemSelect){
       addForm.getForm().findField('type1').setValue('');
       addForm.getForm().findField("type1").clearValue();
       addForm.getForm().findField("type2").clearValue();
       store2.load({params:{parentId:addForm.getForm().findField('category').getValue(),level:2}});
      }
    }]
   },{
    xtype: 'fieldcontainer',
    layout: 'hbox',
    defaultType: 'textfield',
    items: [{
     name:'type1',
     hiddenName:'type1',
     width: 230,
     xtype : 'combobox',
     displayField : 'name',
     valueField : 'code',
     queryMode : 'local',
     editable:false,
     fieldLabel:'大类',
     allowBlank: false,
     blankText:'大类不能为空!',
     store :store2,
     listeners:{
      select:function(itemSelect){
       addForm.getForm().findField('type2').setValue('');
       addForm.getForm().findField("type2").clearValue();
       store3.load({params:{parentId:addForm.getForm().findField('type1').getValue(),level:3}});
      }
     }
    },{
     name:'type2',
     hiddenName:'type2',
     width: 230,
     xtype : 'combobox',
     displayField : 'name',
     valueField : 'code',
     queryMode : 'local',
     editable:false,
     fieldLabel:'小类',
     allowBlank: false,
     blankText:'小类不能为空!',
     store : store3
    }]
   }  ]
  }); 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ExtJs中一个完整GridPanel实例(转)
Extjs4中up()和down()的用法(1)
extjs---form表单基础1
extjs 提交表单(注意Form必须的规定) , 取JSP返回值 , 转换JSON数据为...
Extjs和struts2 做的上传
局部刷新树 Ext
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服