1个回答
展开全部
给你个例子,这样子应该就可以了.最好能帮到你
Ext.util.Format.comboRenderer = function (combo) {
return function (value) {
var record = combo.findRecord(combo.valueField, value);
return record
? record.get(combo.displayField)
: combo.valueNotFoundText;
};
};
var combo = Ext.create("Ext.form.ComboBox", {
typeAhead: true,
triggerAction: 'all',
lazyRender: true,
mode: 'local',
editable: false,
store: new Ext.data.ArrayStore({
id: 0,
fields: ['sName', 'sValue'],
data: [['是', 1], ['否', 0]]
}),
valueField: 'sValue',
displayField: 'sName'
});
var grid = Ext.create('Ext.grid.Panel', {
renderTo: document.body,
autoWidth: true,
height: 200,
frame: true,
title: '答案',
store: gridStore,
iconCls: 'icon-grid',
selModel: Ext.create('Ext.selection.CheckboxModel', {
mode: 'SINGLE',
hidden: true
}),
columns: [Ext.create('Ext.grid.RowNumberer'), {
header: '答案',
field: Ext.create("Ext.form.Text", { value: '' }),
sortable: true,
dataIndex: 'answer'
}, {
header: "是否为正确答案",
width: 120,
dataIndex: 'isRight',
field: combo,
renderer: Ext.util.Format.comboRenderer(combo),
sortable: true
}]
})
Ext.util.Format.comboRenderer = function (combo) {
return function (value) {
var record = combo.findRecord(combo.valueField, value);
return record
? record.get(combo.displayField)
: combo.valueNotFoundText;
};
};
var combo = Ext.create("Ext.form.ComboBox", {
typeAhead: true,
triggerAction: 'all',
lazyRender: true,
mode: 'local',
editable: false,
store: new Ext.data.ArrayStore({
id: 0,
fields: ['sName', 'sValue'],
data: [['是', 1], ['否', 0]]
}),
valueField: 'sValue',
displayField: 'sName'
});
var grid = Ext.create('Ext.grid.Panel', {
renderTo: document.body,
autoWidth: true,
height: 200,
frame: true,
title: '答案',
store: gridStore,
iconCls: 'icon-grid',
selModel: Ext.create('Ext.selection.CheckboxModel', {
mode: 'SINGLE',
hidden: true
}),
columns: [Ext.create('Ext.grid.RowNumberer'), {
header: '答案',
field: Ext.create("Ext.form.Text", { value: '' }),
sortable: true,
dataIndex: 'answer'
}, {
header: "是否为正确答案",
width: 120,
dataIndex: 'isRight',
field: combo,
renderer: Ext.util.Format.comboRenderer(combo),
sortable: true
}]
})
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询