Extjs combo数据绑定与获取
2012-08-09 18:19
281 查看
1、
配置combo:
{
columnWidth: .3,
layout: 'form',
border: false,
items: [{
id: "txtP_Nation",
name: "txtP_Nation",
allowBlank: false,
width: 130,
fieldLabel: '民族',
emptyText: '请选择民族',
hiddenName: 'PM_id', //真正提交时此combo的name,请一定要注意
xtype: 'combo',
editable: false,
store: strNation,//设置数据源
displayField: 'PM_Name', //显示文本字段
valueField: 'PM_id',//value值字段id
mode: 'local',
triggerAction: 'all',,//请设置为"all",否则默认为"query"的情况下,你选择某个值后,再此下拉时,只出现匹配选项,如果设为"all"的话,每次下拉均显示全部选项
selectOnFocus: true,
typeAhead: true
}]
}
2、数据源:
var strNation = new Ext.data.Store({
proxy: new Ext.data.HttpProxy(
{
url: '../form/Ala_HomeOtherPeople.ashx?cmd=GetParmater&type=nation'
}
),
reader: new Ext.data.JsonReader(
{ root: 'data' },
[
{ name: 'PM_id', type: 'string' },//id
{ name: 'PM_Name', type: 'string' }//名称
]
)
});
strNation.load();
编辑或修改数据时需要把要修改的数据显示在combo中:
strNation.load({ callback: function () {
Ext.getCmp("txtP_Nation").setValue(json.P_Nation);//json.P_Nation 为数据id
}
});
获取combo选中的id值:
var P_Nation = Ext.getCmp("txtP_Nation").getValue();
配置combo:
{
columnWidth: .3,
layout: 'form',
border: false,
items: [{
id: "txtP_Nation",
name: "txtP_Nation",
allowBlank: false,
width: 130,
fieldLabel: '民族',
emptyText: '请选择民族',
hiddenName: 'PM_id', //真正提交时此combo的name,请一定要注意
xtype: 'combo',
editable: false,
store: strNation,//设置数据源
displayField: 'PM_Name', //显示文本字段
valueField: 'PM_id',//value值字段id
mode: 'local',
triggerAction: 'all',,//请设置为"all",否则默认为"query"的情况下,你选择某个值后,再此下拉时,只出现匹配选项,如果设为"all"的话,每次下拉均显示全部选项
selectOnFocus: true,
typeAhead: true
}]
}
2、数据源:
var strNation = new Ext.data.Store({
proxy: new Ext.data.HttpProxy(
{
url: '../form/Ala_HomeOtherPeople.ashx?cmd=GetParmater&type=nation'
}
),
reader: new Ext.data.JsonReader(
{ root: 'data' },
[
{ name: 'PM_id', type: 'string' },//id
{ name: 'PM_Name', type: 'string' }//名称
]
)
});
strNation.load();
编辑或修改数据时需要把要修改的数据显示在combo中:
strNation.load({ callback: function () {
Ext.getCmp("txtP_Nation").setValue(json.P_Nation);//json.P_Nation 为数据id
}
});
获取combo选中的id值:
var P_Nation = Ext.getCmp("txtP_Nation").getValue();
相关文章推荐
- [转]Extjs combo数据绑定与获取
- ExtJS combo 从数据库抽取数据动态绑定下拉菜单及获取值
- 使用ExtJS GridPanel从Web Service 获取、绑定和显示数据
- ExtJs4 中 获取grid列表数据绑定到form表单
- 使用ExtJS GridPanel从Web Service 获取、绑定和显示数据
- 使用ExtJS GridPanel从Web Service 获取、绑定和显示数据
- 在FormView控件中嵌套数据绑定控件的问题,以及从一个对象中反射获取属性值的简单办法
- Extjs4 操作TreeStore 处理proxyAjax 获取的数据
- Silverlight Wcf 获取集合数据并绑定(DataContract,DataMember)
- Jquery 模板插件 jquery.tmpl.js 的使用方法(1):基本语法,绑定,each循环,ajax获取json数据
- TreeList获取TreeListNode绑定的数据
- swing jtable绑定数据库 获取用户选择行的数据
- Extjs创建form表单以及绑定动态数据到grid
- 菜鸟学Asp.Net——GridView控件之RowDataBind事件中如何获取已绑定的数据
- Ajax实现无刷新的获取数据并绑定到GridView,以及无刷新更新数据
- droplist在后台绑定数据,在后天怎么获取选中的值?
- $(obj).data() 绑定和获取数据的应用
- Struts2学习3——数据绑定及获取Session
- extjs grid summary 获取平均分数据,并传递object后后台,存储得到想要的数据。
- Ajax无刷新的获取数据绑定GridView及无刷新更新数据