这段代码中,页面加载时,firebug显示processList.action被调用了两次,这是为什么?另外,选中一条数据,点击“流程定义”按钮后,仅弹出窗口,却不显示数据,但firebug显示数据已经加载了,究竟是哪儿有问题?请大家帮忙看看
Ext.ns('Flow.processList');
Flow.processList = function(){
var store;
var sm;
var colModel;
var grid;
return{
getStore:function(){
store = new Ext.data.JsonStore({
root: 'result',
totalProperty: 'totalCount',
remoteSort:false,
storeId: 'processListId',
autoDestroy: true,
fields:['processId','processName','processVersion'],
proxy: new Ext.data.HttpProxy({
url: 'processList.action'
}),
autoLoad: true,
sortInfo: {field:'processId',direction: 'ASC'}
});
//store.load();
return store;
},
getSmModel: function(){
sm = new Ext.grid.CheckboxSelectionModel({
handleMouseDown: Ext.emptyFn //点击行时,不选中此行,要使的点击时,自动选中行,去掉此参数
});
return sm;
},
getColModel:function(){
colModel = new Ext.grid.ColumnModel({
columns: [
new Ext.grid.RowNumberer(),
{ header: "流程ID",dataIndex:'processId', sortable: true},
{ header: "流程名称",dataIndex:'processName'},
{ header: "流程版本",dataIndex:'processVersion'},
this.getSmModel(),
],
defaults: {
sortable: true
}
});
return colModel;
},
getGrid:function(){
grid = new Ext.grid.GridPanel({
id: 'processListGrid',
title:'流程列表',
store: this.getStore(),
cm: this.getColModel(),
//colModel: this.colModel,
sm: this.getSmModel(),
viewConfig:{
forceFit: true
},
tbar: [{
iconCls: '',
text: '启动流程',
handler:this.startProcess
},'-',{
iconCls: '',
text: '删除流程',
//disabled: true,
handler: this.removeProcess
},'-',
{
iconCls: '',
text: '流程定义',
handler: this.getProcessDefinition
},'-',{
iconCls: '',
text: '流程图',
handler: this.getProcessImage
}
],
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: this.getStore(),
displayInfo: true,
displayMsg: '显示流程 {0} - {1} of {2}',
emptyMsg: "没有流程可显示",
items:[
'-', {
pressed: true,
enableToggle:true,
text: 'Show Preview',
cls: 'x-btn-text-icon details',
toggleHandler: function(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
}]
})
});
return grid;
},
startProcess: function(){
if(!sm){
sm = this.getSmModel();
}
var s = sm.getSelections()
var process = s[0].data.processId;
if(!process){
Ext.Msg.alert('信息','未选择任何流程');
return false;
}
else{
Ext.Ajax.request({
url: 'startProcess.action?processId=' + process,
success: function(response, opts) {
var json = response.responseText||response.responseData;
var result = Ext.decode(json);
Ext.Msg.alert('信息',result.message);
},
failure: function() {
Ext.Msg.alert("错误","启动流程失败!");
},
scope: this
});
}
},
removeProcess: function(){
if(!sm){
sm = this.getSmModel();
}
var s = sm.getSelections()
var process = s[0].data.processId;
if(!process){
Ext.Msg.alert('信息','未选择任何流程');
return false;
}
else{
Ext.Ajax.request({
url: 'deleteProcess.action?processId=' + process,
success: function(response, opts) {
var json = response.responseText||response.responseData;
var result = Ext.decode(json);
Ext.Msg.alert('信息',result.message);
},
failure: function() {
Ext.Msg.alert("错误","删除流程失败!");
},
scope: this
});
}
},
getProcessDefinition: function(){
if(!sm){
sm = this.getSmModel();
}
var s = sm.getSelections()
var process = s[0].data.processId;
if(!process){
Ext.Msg.alert('信息','请选择要查看的流程');
return false;
}
else{
var processGrid = new Ext.grid.GridPanel({
store: new Ext.data.JsonStore({
root: 'resultSet',
autoDestroy: true,
fields:['processDefinition'],
proxy: new Ext.data.HttpProxy({
url: 'processDefinition.action?processId='+process
}),
autoLoad: true
}),
columns: [
{header: "流程定义", dataIndex: 'processDefinition'}
],
viewConfig: {
forceFit: true,
},
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
// width:600,
// height:300,
frame:true,
title:'',
iconCls:'icon-grid'
});
var win = new Ext.Window({
id: 'processWin',
width: 600,
height: 300,
title: '流程定义',
plain: true,
closable: true,
//resizable: false,
frame: true,
layout: 'fit',
autoScroll: true,
border: false,
modal: true,
items:[processGrid]
});
win.show();
}
},
getProcessImage: function(){
//TODO
},
render: function(tab){
if(!this.grid){
this.grid = this.getGrid();
tab.add(this.grid);
}
}
}
};
Ext.onReady(function(){
var win = new Ext.Window({});
var f = new Flow.processList();
f.render(win);
win.show();
});