new Ext.grid.EditorGridPanel({
store:new Ext.data.ArrayStore({fields:['ItemCode','ItemName','ItemExplain','ItemStyle','ItemValue','DetailID'],data:[]}),
height:155,
viewConfig:{forceFit:true},
bodyStyle:'width:100%',
clicksToEdit:1,
columns:[
{header:"项目名称",dataIndex:'ItemName',resizable:false,menuDisabled:true,width:120},
{header:"项目值",dataIndex:'ItemValue',resizable:false,menuDisabled:true,width:150},
{header:"项目描述",dataIndex:'ItemExplain',resizable:false,menuDisabled:true,editor:new Ext.form.TextField({ })}
],
frame:true,
listeners:{beforeedit:function(e){
SelectedItemCode=e.record['data']['ItemCode'];
SelectedItemStyle=e.record['data']['ItemStyle'];
},cellclick:function(grid,rowIndex,columnIndex,e){
if(columnIndex!=1)
return
var record = grid.getStore().getAt(rowIndex);
var grdEditor = grid.colModel.getCellEditor(columnIndex,rowIndex);
if (grdEditor){grdEditor.destroy(); }
var NewComboEditor=new Ext.grid.GridEditor(new Ext.form.ComboBox({
store:new Ext.data.ArrayStore({fields:['ValueZJM','ValueDisplayName','ValueName'],data:[]}),
displayField:'ValueDisplayName',
selectOnFocus:true,
mode:'local',
triggerAction:'all',
handleHeight:10,
editable:false,
resizable:true,
listeners:{
specialkey:function(combo,e){
if(e.getKey()=="13"){
var CurrentGrid=Ext.getCmp("ExtendedAttrTab").getActiveTab().findByType("grid")[0];
var CurrentCell=CurrentGrid.getSelectionModel().getSelectedCell();
CurrentGrid.startEditing(CurrentCell[0],2);
}
},
beforeshow:function(combo){
Ext.Ajax.request({
url:'AttrTable.ashx?method=queryItem',
params:{itemCodeForValue:SelectedItemCode},
callback:function(options,success,response){
if(success){
combo.getStore().loadData(eval('('+response.responseText+')'))
}
}
})
}
}
}));
NewComboEditor.on("beforedestroy" ,function( Editor,value,startValue){return false;})
var NewLovComboEditor=new Ext.grid.GridEditor(new Ext.ux.form.LovCombo({
store:new Ext.data.ArrayStore({fields:['ValueZJM','ValueDisplayName','ValueName'],data:[]}),
triggerAction:'all',
editable:false,
displayField:'ValueDisplayName',
valueField:'ValueName',
mode:'local',
handleHeight:10,
editable:false,
//beforeBlur:function(){},
anchor:"95%",
listeners:{
specialkey:function(combo,e){
if(e.getKey()=="13"){
var CurrentGrid=Ext.getCmp("ExtendedAttrTab").getActiveTab().findByType("grid")[0];
var CurrentCell=CurrentGrid.getSelectionModel().getSelectedCell();
CurrentGrid.startEditing(CurrentCell[0],2);
}
},
beforeshow:function(combo){
Ext.Ajax.request({
url:'AttrTable.ashx?method=queryItem',
params:{itemCodeForValue:SelectedItemCode},
callback:function(options,success,response){
if(success){
combo.getStore().loadData(eval('('+response.responseText+')'))
}
}
})
}
}
}))
NewLovComboEditor.on("beforedestroy" ,function( Editor,value,startValue){return false;})
var NewNumberEditor=new Ext.grid.GridEditor(new Ext.form.NumberField({
listeners:{
specialkey:function(combo,e){
if(e.getKey()=="13"){
var CurrentGrid=Ext.getCmp("ExtendedAttrTab").getActiveTab().findByType("grid")[0];
var CurrentCell=CurrentGrid.getSelectionModel().getSelectedCell();
CurrentGrid.startEditing(CurrentCell[0],2);
}
}
}
}));
switch(record.get('ItemStyle')){
case '0'://数字型
grid.colModel.setEditor(columnIndex,NewNumberEditor);
break
case '1'://文字型
grid.colModel.setEditor(columnIndex, new Ext.grid.GridEditor(new Ext.form.ComboBox({
store:new Ext.data.ArrayStore({fields:['ValueZJM','ValueDisplayName','ValueName'],data:[]}),
displayField:'ValueDisplayName',
mode:'local',
triggerAction:'all',
handleHeight:10,
editable:true,
resizable:true,
listeners:{
change:function(combo,newValue,oldValue){
var result=combo.getStore().query("ValueZJM", newValue,false).first();
if(result!=null){combo.setValue(result["data"].ValueName);}else{
result=combo.getStore().query("ValueDisplayName",newValue,false).first();
if(result!=null){combo.setValue(result["data"].ValueName);}else{combo.setValue(newValue)}
}
},
specialkey:function(combo,e){
if(e.getKey()=="13"||e.getKey()=="9"){
var result=combo.getStore().query("ValueZJM",combo.getValue(),false).first();
if(result!=null){combo.setValue(result["data"].ValueName);}else{
result=combo.getStore().query("ValueDisplayName",combo.getValue(),false).first();
if(result!=null){combo.setValue(result["data"].ValueName);}else{combo.setValue(combo.getValue())}
}
};
if(e.getKey()=="13"){
var CurrentGrid=Ext.getCmp("ExtendedAttrTab").getActiveTab().findByType("grid")[0];
var CurrentCell=CurrentGrid.getSelectionModel().getSelectedCell();
CurrentGrid.startEditing(CurrentCell[0],2);
}
},
beforeshow:function(combo){
combo.getStore().removeAll();
Ext.Ajax.request({
url:'AttrTable.ashx?method=queryItem',
params:{itemCodeForValue:SelectedItemCode},
callback:function(options,success,response){
if(success){
combo.getStore().loadData(eval('('+response.responseText+')'))
}
}
})
}
}
})));
break;
case '2'://单选型
grid.colModel.setEditor(columnIndex,NewComboEditor);
break;
case '3'://多选型
grid.colModel.setEditor(columnIndex,NewLovComboEditor);
break;
}
}
}
})