Ext.onReady(function() {
Ext.tip.QuickTipManager.init();
// Define the model for a State
Ext.define('State', {
extend: 'Ext.data.Model',
fields: [
{type: 'string', name: 'code'},
{type: 'string', name: 'name'}
]
});
// The data for all states
// The data store holding the states; shared by each of the ComboBox examples below
var store = new Ext.data.Store({
model: 'State'
});
// Simple ComboBox using the data store
var littletype = Ext.create('Ext.form.field.ComboBox', {
id:'dailyReport_lookups_name',
renderTo: 'littletype',
displayField: 'name',
valueField: 'code',
store: store,
width: 150,
editable:false,
name: 'dailyReport.lookups.name',
hiddenName:'dailyReport.lookups.code',
hiddenValue:'code',
typeAhead: true,
queryMode: 'local',
emptyText: '请选择',
blankText: '请选择',
listeners: {
"select": function (combo, record, index) {
document.getElementById("dailyReport.lookups.code").value=combo.value;
}
}
});
});
function onload(){
if(document.all('dailyReport.category.code').value!='请选择')
{
Ext.getCmp('dailyReport_lookups_name').store.proxy.url='getLookupsListopinion.action?code='+document.all('dailyReport.category.code').value;
Ext.getCmp('dailyReport_lookups_name').store.load();
}
}
</script>我想保存CODE,但是lookups这个对象里面传过来的就只有name,求各位大侠帮忙看看
Ext.tip.QuickTipManager.init();
// Define the model for a State
Ext.define('State', {
extend: 'Ext.data.Model',
fields: [
{type: 'string', name: 'code'},
{type: 'string', name: 'name'}
]
});
// The data for all states
// The data store holding the states; shared by each of the ComboBox examples below
var store = new Ext.data.Store({
model: 'State'
});
// Simple ComboBox using the data store
var littletype = Ext.create('Ext.form.field.ComboBox', {
id:'dailyReport_lookups_name',
renderTo: 'littletype',
displayField: 'name',
valueField: 'code',
store: store,
width: 150,
editable:false,
name: 'dailyReport.lookups.name',
hiddenName:'dailyReport.lookups.code',
hiddenValue:'code',
typeAhead: true,
queryMode: 'local',
emptyText: '请选择',
blankText: '请选择',
listeners: {
"select": function (combo, record, index) {
document.getElementById("dailyReport.lookups.code").value=combo.value;
}
}
});
});
function onload(){
if(document.all('dailyReport.category.code').value!='请选择')
{
Ext.getCmp('dailyReport_lookups_name').store.proxy.url='getLookupsListopinion.action?code='+document.all('dailyReport.category.code').value;
Ext.getCmp('dailyReport_lookups_name').store.load();
}
}
</script>我想保存CODE,但是lookups这个对象里面传过来的就只有name,求各位大侠帮忙看看
valueField: 'code',这个写错了。
应改成:
displayField: 'name',
valueField: 'type',
var left_set_l = {
layout : 'form',
labelAlign:'right',
columnWidth : .5,
items : [{
xtype : 'fieldset',
anchor : '95%',
title : '报表对象范围设置',
collapsible : true,
autoHeight : true,
hideBorders : true,
items : [{
anchor : '90%',
hideTrigger1:true,
xtype:'combo',
id:'app_output_stattype',
name:'app_output_stattype',
fieldLabel:'统计对象类型',
store:new Ext.data.SimpleStore({
fields:['typeId','typeName'],
data:[['1','用户'],['2','网络应用']]
}),
onSelect : function (val) {
this.setValue(val.data.typeId);
this.collapse();
app_output_panel.isSubmit=false;
},
valueField:'typeId',
displayField:'typeName',
mode:'local',
triggerAction:'all',
editable : false,
value:''
}]
}]
}以上是我的,定的死值,没从数据库取。var controlName_stroe_web = new Ext.data.JsonStore({
url : 'queryComboxList',
baseParams : {
'combox.type' : 'netcontrolName'
},
fields : [ {
name : 'code'
}, {
name : 'name'
}]
});{
xtype : 'combo',
fieldLabel : '<font color=red>控制策略</font>',
id:'controlName',
name : 'controlName',
store : controlName_stroe_web,
displayField : 'name',
valueField : 'code',
typeAhead : true,
editable : false,
triggerAction : 'all',
selectOnFocus : true,
mode : 'remote',
hiddenName : 'websiteFilter.controlName',
allowBlank:false,
blankText:'控制策略不能为空',
msgTarget:'under',
anchor : '100%'
}
以上是从数据库取值
xtype:'combo',
store:styleStore,
valueField :"styleName",
displayField: "styleName",
//数据是在本地
queryMode: 'local',
forceSelection: true,//必须选择一项
emptyText:'请选择子分类...',//默认值
name:'leave.tbLeavestyle.styleName',//hiddenName才是提交到后台的input的name
editable: false,//不允许输入
triggerAction: 'all',//因为这个下拉是只能选择的,所以一定要设置属性triggerAction为all
allowBlank:false,//该选项值不能为空
fieldLabel: '类型',
width : '300',
listeners: {
"focus": function() {
styleStore.loadPage(1);
}
}demo 自己看看!!