totodo
6 Apr 2007, 2:39 AM
Hi,:)
look at the pic.
my Code is :
var cutTask4AssignLine = function(){
this.grid={};
this.ds={};
return {
createGrid:function(){
var devDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '../cutTask.do?method=findCutDevice&rscSpecId=10301001'
}),
reader: new Ext.data.JsonReader({
root: 'devResult',
totalProperty: 'totalResults',
id: 'DEVICE_ID'
}, [
{name: 'deviceId', mapping: 'DEVICE_ID'},
{name: 'devCode', mapping: 'DEVICE_CODE'},
{name: 'deviceName', mapping: 'DEV_NAME'},
{name: 'area', mapping: 'AREA_NAME'}
])
});
// Custom rendering Template
var resultTpl = new Ext.Template(
'<div class="search-item">',
'<h3><span>{devCode}</span>-{deviceName}</h3>',
'{area}',
'</div>'
);
var taskId = $('taskOps').value;
var CutTask = Ext.data.Record.create([
{name:'taskId', mapping: 'TASK_ID'},
{name: 'taskAtomId', mapping: 'TASK_ATOM_ID'},
{name: 'cutAtomName', mapping: 'CUT_ATOM_NAME'},
{name: 'oldDevName', mapping: 'OLD_DEV_NAME'},
{name: 'oldDevId', mapping: 'OLD_DEV_ID'},
{name: 'oldPortStartValue', mapping: 'OLD_PORT_START_VALUE'},
{name: 'oldPortEndValue', mapping: 'OLD_PORT_END_VALUE'},
{name: 'portTypeName', mapping: 'PORT_TYPE_NAME'},
{name: 'cutObjName',mapping:'CUT_OBJ_NAME'},
{name: 'newDevId',mapping:'NEW_DEV_ID'},
{name: 'newPortStartValue',mapping:'NEW_PORT_START_VALUE',type:'string'},
{name: 'newPortEndValue',mapping:'NEW_PORT_END_VALUE',type:'string'},
{name: 'newDevName',mapping:'NEW_DEV_NAME'}
]);
Ext.QuickTips.init();
var fm = Ext.form, Ed = Ext.grid.GridEditor;
var reader = new Ext.data.JsonReader({
root: 'cutTasks',
totalProperty: 'totalCount',
id: 'TASK_ATOM_ID'
}, CutTask);
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '../cutTask.do?method=findCut2AtomsByTask'
}),
reader: reader
});
this.ds=ds;
function renderCheckBox(id){
return String.format('<input type="checkbox" id={0}"></input>',id);
}
function renderTopicPlain(value){
return String.format('<b>{0}</b>', value);
}
var cm =new Ext.grid.ColumnModel([
{header: "选择", width: 30, dataIndex: 'taskAtomId',renderer: renderCheckBox},
{header: "割接特性", width: 80, dataIndex: 'cutAtomName',renderer: renderTopicPlain},
{header: "原设备", width: 120, dataIndex: 'oldDevName',renderer: renderTopicPlain},
{header: "原设备起始值", width: 100, dataIndex: 'oldPortStartValue'},
{header: "原设备终止值", width: 100, dataIndex: 'oldPortEndValue'},
{header: "原设备割接类型", width: 80, dataIndex: 'portTypeName'},
{header: "新设备", width: 120, dataIndex: 'newDevName',
editor: new Ed(new Ext.form.ComboBox({
id:'devInput',
store: devDS,
displayField:'devName',
typeAhead: false,
triggerAction: 'all',
loadingText: 'Searching...',
minListWidth : 250,
width: 400,
queryParam: 'query',
pageSize:10,
hideTrigger:true,
tpl: resultTpl,
forceSelection:true,
onSelect: function(record){ // override default onSelect to do redirect
//选中回车
//alert(record.data.deviceId+','+record.id);
}
}))},
{header: "新设备起始值", width: 100, dataIndex: 'newPortStartValue',
editor: new Ed(new fm.TextField({
allowBlank: true
}))},
{header: "新设备起始值", width: 100, dataIndex: 'newPortEndValue',
editor: new Ed(new fm.TextField({
allowBlank: true
}))}
]);
cm.defaultSortable = true;
var grid = new Ext.grid.EditorGrid('cutTask-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel(),
enableColLock:false
});
this.grid=grid;
grid.render();
grid.on('afteredit', this.afteredit, this, true);
grid.on('cellclick',this.launchDetail,this);
ds.load();
//ds.on("load",this.onEndUpdate);
//ds.on("beforeload",this.onBeginUpdate);
var gridFoot = grid.getView().getFooterPanel(true);
var toolBar = new Ext.Toolbar(gridFoot);
toolBar.addButton({
text:'按文件分配',
enableToggle:true,
id:'assignByFile',
toggleHandler:this.assignLineByFile.createDelegate(this)
});
toolBar.addButton({
text:'分配',
id:'assignAuto',
enableToggle:true,
toggleHandler:this.assignLine.createDelegate(this)
});
toolBar.addButton({
text:'取消分配',
id:'cancelAssign'
});
toolBar.addText("【操作结果】<span id='msg' style='color: red'></span>");
//载入数据
Ext.get('qryBtn').on('click',function(){
taskId = $("taskOps").value;
var atomId = document.forms[0].atomId;
ds.proxy = new Ext.data.HttpProxy({
url: '../cutTask.do?method=findCut2AtomsByTask'
});
ds.baseParams ={taskId:taskId,atomId:atomId};
ds.load();
});
},
My question is :
how can i update the editing cell set its' value = recorder.data.filed ?
look at the pic.
my Code is :
var cutTask4AssignLine = function(){
this.grid={};
this.ds={};
return {
createGrid:function(){
var devDS = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '../cutTask.do?method=findCutDevice&rscSpecId=10301001'
}),
reader: new Ext.data.JsonReader({
root: 'devResult',
totalProperty: 'totalResults',
id: 'DEVICE_ID'
}, [
{name: 'deviceId', mapping: 'DEVICE_ID'},
{name: 'devCode', mapping: 'DEVICE_CODE'},
{name: 'deviceName', mapping: 'DEV_NAME'},
{name: 'area', mapping: 'AREA_NAME'}
])
});
// Custom rendering Template
var resultTpl = new Ext.Template(
'<div class="search-item">',
'<h3><span>{devCode}</span>-{deviceName}</h3>',
'{area}',
'</div>'
);
var taskId = $('taskOps').value;
var CutTask = Ext.data.Record.create([
{name:'taskId', mapping: 'TASK_ID'},
{name: 'taskAtomId', mapping: 'TASK_ATOM_ID'},
{name: 'cutAtomName', mapping: 'CUT_ATOM_NAME'},
{name: 'oldDevName', mapping: 'OLD_DEV_NAME'},
{name: 'oldDevId', mapping: 'OLD_DEV_ID'},
{name: 'oldPortStartValue', mapping: 'OLD_PORT_START_VALUE'},
{name: 'oldPortEndValue', mapping: 'OLD_PORT_END_VALUE'},
{name: 'portTypeName', mapping: 'PORT_TYPE_NAME'},
{name: 'cutObjName',mapping:'CUT_OBJ_NAME'},
{name: 'newDevId',mapping:'NEW_DEV_ID'},
{name: 'newPortStartValue',mapping:'NEW_PORT_START_VALUE',type:'string'},
{name: 'newPortEndValue',mapping:'NEW_PORT_END_VALUE',type:'string'},
{name: 'newDevName',mapping:'NEW_DEV_NAME'}
]);
Ext.QuickTips.init();
var fm = Ext.form, Ed = Ext.grid.GridEditor;
var reader = new Ext.data.JsonReader({
root: 'cutTasks',
totalProperty: 'totalCount',
id: 'TASK_ATOM_ID'
}, CutTask);
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '../cutTask.do?method=findCut2AtomsByTask'
}),
reader: reader
});
this.ds=ds;
function renderCheckBox(id){
return String.format('<input type="checkbox" id={0}"></input>',id);
}
function renderTopicPlain(value){
return String.format('<b>{0}</b>', value);
}
var cm =new Ext.grid.ColumnModel([
{header: "选择", width: 30, dataIndex: 'taskAtomId',renderer: renderCheckBox},
{header: "割接特性", width: 80, dataIndex: 'cutAtomName',renderer: renderTopicPlain},
{header: "原设备", width: 120, dataIndex: 'oldDevName',renderer: renderTopicPlain},
{header: "原设备起始值", width: 100, dataIndex: 'oldPortStartValue'},
{header: "原设备终止值", width: 100, dataIndex: 'oldPortEndValue'},
{header: "原设备割接类型", width: 80, dataIndex: 'portTypeName'},
{header: "新设备", width: 120, dataIndex: 'newDevName',
editor: new Ed(new Ext.form.ComboBox({
id:'devInput',
store: devDS,
displayField:'devName',
typeAhead: false,
triggerAction: 'all',
loadingText: 'Searching...',
minListWidth : 250,
width: 400,
queryParam: 'query',
pageSize:10,
hideTrigger:true,
tpl: resultTpl,
forceSelection:true,
onSelect: function(record){ // override default onSelect to do redirect
//选中回车
//alert(record.data.deviceId+','+record.id);
}
}))},
{header: "新设备起始值", width: 100, dataIndex: 'newPortStartValue',
editor: new Ed(new fm.TextField({
allowBlank: true
}))},
{header: "新设备起始值", width: 100, dataIndex: 'newPortEndValue',
editor: new Ed(new fm.TextField({
allowBlank: true
}))}
]);
cm.defaultSortable = true;
var grid = new Ext.grid.EditorGrid('cutTask-grid', {
ds: ds,
cm: cm,
selModel: new Ext.grid.RowSelectionModel(),
enableColLock:false
});
this.grid=grid;
grid.render();
grid.on('afteredit', this.afteredit, this, true);
grid.on('cellclick',this.launchDetail,this);
ds.load();
//ds.on("load",this.onEndUpdate);
//ds.on("beforeload",this.onBeginUpdate);
var gridFoot = grid.getView().getFooterPanel(true);
var toolBar = new Ext.Toolbar(gridFoot);
toolBar.addButton({
text:'按文件分配',
enableToggle:true,
id:'assignByFile',
toggleHandler:this.assignLineByFile.createDelegate(this)
});
toolBar.addButton({
text:'分配',
id:'assignAuto',
enableToggle:true,
toggleHandler:this.assignLine.createDelegate(this)
});
toolBar.addButton({
text:'取消分配',
id:'cancelAssign'
});
toolBar.addText("【操作结果】<span id='msg' style='color: red'></span>");
//载入数据
Ext.get('qryBtn').on('click',function(){
taskId = $("taskOps").value;
var atomId = document.forms[0].atomId;
ds.proxy = new Ext.data.HttpProxy({
url: '../cutTask.do?method=findCut2AtomsByTask'
});
ds.baseParams ={taskId:taskId,atomId:atomId};
ds.load();
});
},
My question is :
how can i update the editing cell set its' value = recorder.data.filed ?