Ext.define(
'pns.common.ComboColumn'
, {
extend:
'Ext.grid.Column'
,
alias:
'widget.pns.combocolumn'
,
initComponent:
function
() {
var
me =
this
;
me.callParent();
var
editor =
this
.editor ||
this
.field
store = editor.store;
store.on(
'load'
,
function
() { me.up(
'gridpanel'
).getView().refresh() });
},
renderer:
function
(value, metaData, record, rowIndex, colIndex, store) {
var
column =
this
.columns[colIndex],
editor = column.editor || column.field,
comboStore = editor.store,
displayField = editor.displayField;
index = comboStore.findExact(editor.valueField, value);
if
(index != -1){
rs = comboStore.getAt(index).data;
record.set(editor.updateNameField, eval(
'rs.'
+displayField));
console.log(
'변경된 레코드 '
, editor.updateNameField, displayField, eval(
'rs.'
+displayField), record)
return
eval(
'rs.'
+displayField);
}
return
value;
}
});
Ext.define(
'pns.common.CodeComboBox'
, {
extend:
'Ext.form.field.ComboBox'
,
alias:
'widget.commonCbx'
,
labelAlign:
'right'
,
labelWidth: 75,
initComponent:
function
(){
var
me =
this
;
var
task =
new
Ext.util.DelayedTask(
function
(){
me.codeFieldCreate(me);
});
task.delay(1000);
this
.on(
'select'
,
this
.onSelectChanged,
this
);
this
.store = Ext.create(
'Ext.data.Store'
, {
autoLoad:
this
.autoload,
fields: [
'code'
,
'code_name'
,
'cd_amt'
],
proxy: {
type:
'ajax'
,
url:
'/json/code.jsp?codes'
,
reader: {
type:
'json'
,
root:
'entitys'
}
},
extraParams: {
notInCode:
this
.notInCode,
likeCode:
this
.likeCode,
likeCodeDesc:
this
.likeCodeDesc,
group_code:
this
.groupCode
}
});
this
.callParent(arguments);
var
store =
this
.store;
this
.store.on(
'load'
,
function
() { me.setValue(me.getValue()) });
},
codeFieldCreate :
function
(){
if
(!
this
.codefield)
return
;
this
.up(
'form'
).add({
xtype :
'hiddenfield'
,
name :
this
.codefield
});
},
onSelectChanged:
function
(combo, t) {
if
(!
this
.codefield)
return
;
var
form =
this
.up(
'form'
).getForm();
form.findField(
this
.codefield).setValue(t[0].get(
'code'
));
form.findField(
this
.name).setValue(t[0].get(
'code_name'
));
},
displayField :
'code_name'
,
valueField :
'code'
,
typeAhead :
true
,
editable :
false
,
lazyRender:
true
});
var
mst_use_yn = Ext.widget(
'commonCbx'
,{
updateNameField :
'mst_use_yn_nm'
,
autoload :
true
,
group_code :
'A001'
});
items : [{
xtype:
'grid'
,
columnLines:
true
,
..
..
{
header:
"상태"
,
width: 70,
xtype:
'pns.combocolumn'
,
dataIndex:
'mst_use_yn'
,
editor : mst_use_yn
}
{
xtype :
'commonCbx'
,
group_code :
'A001'
,
allowBlank:
false
,
fieldLabel:
'심사부문 '
,
name:
'mst_use_yn_nm'
,
codefield:
'mst_use_yn'
,
emptyText:
'심사부문을 선택해주세요'
}