3
Ext.Window를 통해 표시하는 EditorGridPanel이 있습니다.ComboBox는 클릭했을 때 displayField 만 표시합니다.
resources
은 Ajax 호출을 통해 얻은 Json 데이터입니다.
예 데이터 : {"data":[{"id":"1","allowed":"1","roleId":"0","resource":"nothing"}]}
문제는 내가 콤보 상자를 클릭하면 콤보 상자의 displayField 만 표시된다는 점이다. 클릭하면 "허용됨", "허용되지 않음"을 선택할 수 있습니다. 포커스를 제거하면 값이 표시됩니다 : "1", "0".
클릭하지 않은 경우에도 displayField 값을 표시하려면 어떻게해야합니까?
showRoleDetails: function(resources, roleId) {
var rolesData = resources;
var store = new Ext.data.JsonStore({
url: '/plugin/Registration/admin/get-acl-resources-of-role',
baseParams: { role: roleId},
storeId: 'myStore',
root: 'data',
fields: [
{name: 'allowed'},
{name: 'resource'}
]
});
store.load();
var grid = new Ext.grid.EditorGridPanel({
title: "Edit/View permissions for resources",
store: store,
autoHeight: true,
columns: [
{
header: 'Allowed',
dataIndex: 'allowed',
editor: new Ext.form.ComboBox({
triggerAction: 'all',
frame: true,
lazyRender:true,
editable: false,
mode: 'local',
value: 'allowed',
store: new Ext.data.JsonStore({
fields : ['allowed', 'allowedLabel'],
data :
[
{
allowed: '1',
allowedLabel: 'allowed'
},
{
allowed: '0',
allowedLabel: 'not allowed'
}
]
}),
valueField: 'allowed',
displayField: 'allowedLabel'
})
},
{
header: 'Resource',
dataIndex: 'resource'
}
]
});
var window = new Ext.Window({
items: grid
});
window.show();
}
편집 :Following 나렌드라 업에의 반응은, 나는 같은 내 코드 편집 :이 멋지고 작동
var comboBox = new Ext.form.ComboBox({ //Combox values need to be filled up
triggerAction: 'all',
frame: true,
lazyRender:true,
editable: false,
mode: 'local',
value: 'allowed',
store: new Ext.data.JsonStore({
fields : ['allowed', 'allowedLabel'],
data :
[
{
allowed: '1',
allowedLabel: 'allowed'
},
{
allowed: '0',
allowedLabel: 'not allowed'
}
]
}),
valueField: 'allowed',
displayField: 'allowedLabel'
}) ;
var me = this;
var grid = new Ext.grid.EditorGridPanel({
title: "Edit/View permissions for resources",
store: store,
autoHeight: true,
columns: [
{
header: 'Allowed',
dataIndex: 'allowed',
editor: comboBox,
renderer: me.comboBoxRenderer(comboBox)
},
{
header: 'Resource',
dataIndex: 'resource'
}
]
});
.