Octavus 2009-07-28 18:03
浏览 203
已采纳

如何extend可以附带参数的控件【combobox】??

[quote]现在项目里有这样定义继承的控件,这个是不需要带参数的用法,直接查出所有的列表[/quote]
[code="java"]

Ext.app.Module = function(config){
Ext.apply(this, config);
Ext.app.Module.superclass.constructor.call(this);
this.init();
}
//---------
Modules.CreatedUserCombo = Ext.extend(Ext.form.ComboBox,{
store:new Ext.data.JsonStore({
url:'xx.do?format=json',
root:'data.accountList',
fields:['userName']
}),
fieldLabel:'Created User',
displayField:'userName',
valueField:'userName',
triggerAction:'all'
});
Ext.reg('createduser',Modules.CreatedUserCombo);
[/code]
[quote]然后就可以这样使用自定义控件了:[/quote]
[code="java"]
{
xtype : 'createduser',
name : 'createdUser'
}
[/code]
[quote]现在我希望能够使用自带参数,并将参数传递给jsonStore,然后向如下一样使用:[/quote]
[code="java"]
{
xtype : 'createduser',
name : 'createdUser',
baseParams : {customer: id}
}
[/code]
[quote]请问各位高手,该如何定义和使用呢?[/quote]
[b]问题补充:[/b]
[quote]还是不行啊,是不是传值传早了或者传晚了?不知道EXT底层的到底怎么extend的啊。。。[/quote]
[code="java"]Modules.CreatedUserCombo = Ext.extend(Ext.form.ComboBox,{

store:new Ext.data.JsonStore({

url:'xx.do?format=json',

root:'data.accountList',

fields:['userName'],
baseParams: this.baseParams||{},//这样还是显示不了
// baseParams: {customer: '8861008555'}, //这样可以成功
autoLoad : true

}),

fieldLabel:'Created User',

displayField:'userName',

valueField:'userName',

triggerAction:'all'

}); [/code]

  • 写回答

2条回答 默认 最新

  • iteye_10013 2009-07-29 13:51
    关注

    [code="java"]

    Ext.app.Module = function(config){
    Ext.apply(this, config);
    Ext.app.Module.superclass.constructor.call(this);
    this.init();
    }
    //---------
    Modules.CreatedUserCombo = Ext.extend(Ext.form.ComboBox,{
    //在组件初始化期间调用的代码
    initComponent: function(config){
    //调用父类构造函数(必须)
    Modules.CreatedUserComb.superclass.initComponent.apply(this,arguments);
    //调用父类代码之后.如:设置事件处理和渲染组件
    Ext.apply(this,{
    store:new Ext.data.JsonStore({
    url:'xx.do?format=json',
    root:'data.accountList',
    fields:['userName']
    baseParams: config.baseParams||{}
    })
    })

      //或者:
      //this.store = new Ext.data.JsonStore({
      //  url:'xx.do?format=json',
      //  root:'data.accountList',
      //  fields:['userName']
      //  baseParams: this.baseParams||{}
      //})
    },
    fieldLabel:'Created User',
    displayField:'userName',
    valueField:'userName',
    triggerAction:'all'
    

    });
    Ext.reg('createduser',Modules.CreatedUserCombo);

    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建