extjs4-显示一个值而不是它';网格中组合框内的s id
我关于StackOverflow的第一个问题,不要过多地责备我;) 我必须做一个界面,显示一个网格,其中包含从中加载的内容和ajax请求 在这一点上,没有什么困难,我设法创建了一个模型、一个存储和一个代理,以便从我的php/mysql脚本中获取值并在网格上显示它们 但是在返回的数据中,我有一些ID,它们应该被转换为存储在另一个MySQL表中的等价值 在这一点上,我被卡住了,在搜索了几个小时后,我仍然不知道如何将我的id值重新映射到另一个商店/型号的标签上 代码如下: 面板视图:extjs4-显示一个值而不是它';网格中组合框内的s id,extjs,extjs4,Extjs,Extjs4,我关于StackOverflow的第一个问题,不要过多地责备我;) 我必须做一个界面,显示一个网格,其中包含从中加载的内容和ajax请求 在这一点上,没有什么困难,我设法创建了一个模型、一个存储和一个代理,以便从我的php/mysql脚本中获取值并在网格上显示它们 但是在返回的数据中,我有一些ID,它们应该被转换为存储在另一个MySQL表中的等价值 在这一点上,我被卡住了,在搜索了几个小时后,我仍然不知道如何将我的id值重新映射到另一个商店/型号的标签上 代码如下: 面板视图: Ext.defi
Ext.define('Audiotel.views.TimeRangePanelView', {
extend : 'Ext.grid.Panel',
config : {
columns : [{
header : 'Start date',
dataIndex : 'slo_time_start',
editor : {
xtype : 'timefield',
format : 'H:i:s',
increment : 60 // In minutes
},
renderer : function(value, metaData, record, rowIndex, colIndex, store, view) {
return value;
}
}, {
header : 'End Date',
dataIndex : 'slo_time_end',
editor : {
xtype : 'timefield',
format : 'H:i:s',
increment : 60 // In minutes
},
renderer : function(value, metaData, record, rowIndex, colIndex, store, view) {
return value;
}
}, {
header : 'Days',
dataIndex : 'slo_valid_days',
editor : Ext.create('Ext.form.field.ComboBox', {
typeAhead : true,
triggerAction : 'all',
selectOnTab : true,
store : [['Everyday', 'Everyday'], ['WE and holiday', 'WE and holiday'], ['Week', 'Week']],
lazyRender : true,
listClass : 'x-combo-list-small'
})
}, {
header : 'Range',
dataIndex : 'slo_hou_id',
editor : Ext.create('Ext.form.field.ComboBox', {
selectOnTab : true,
store : [['1', 'Peak'], ['2', 'Offpeak'], ['3', 'Night']],
listClass : 'x-combo-list-small',
}),
renderer : function(value, metaData, record, rowIndex, colIndex, store, view) {
return value;
}
}],
height : 400,
width : '100%',
store : Audiotel.stores.StoreBuilder.factory('TimeRange').createStore('getDefaultTimeRange'),
renderTo : "range_table_div",
frame : true
},
constructor : function() {
this.callParent()
}
});
存储生成器(使用代理):
型号:
Ext.define('Audiotel.models.TimeRangeModel', {
extend : 'Ext.data.Model',
alias : 'TimeRange',
fields : [{
name : 'slo_time_start',
type : 'string'
}, {
name : 'slo_time_end',
xtype : 'string'
}, {
name : 'slo_valid_days',
type : 'string'
}, {
name : 'slo_hou_id',
type : 'string'
}]
});
我要转换的值是“slo_hou_id”,它仍然显示“1”而不是“Peak”
提前感谢您的帮助
ps:我对ExtJS非常陌生
编辑:
我为其他表值创建了一个新存储:
Ext.define('Audiotel.models.HoursModel', {
extend : 'Ext.data.Model',
alias : 'Hours',
fields : [{
name : 'hou_id',
type : 'int'
}, {
name : 'hou_label',
xtype : 'string'
}]
});
我已将数据加载到其中:
[{"hou_id":"1","hou_label":"Heures pleines"},{"hou_id":"2","hou_label":"Heures creuses"},{"hou_id":"3","hou_label":"Heures nuit"}]
但当我试图寻找价值时,似乎失败了:
var hours = Audiotel.stores.StoreBuilder.factory('Hours').createStore('getHoursValues');
console.log(hours.getById(1));
console.log(hours.findRecord('hou_id', 1));
全部返回空…:(您有两种选择:
other\u Store.findRecord('slo\u hou\u id',1)。您想要的属性
谢谢你的快速回答,但似乎我仍然缺少一些东西…我正在更新我的原始问题以添加信息。ps:我不能直接返回值,因为我需要在…之后的索引。。。
var hours = Audiotel.stores.StoreBuilder.factory('Hours').createStore('getHoursValues');
console.log(hours.getById(1));
console.log(hours.findRecord('hou_id', 1));