weixin_42393259 2010-08-12 11:03
浏览 312
已采纳

GridPanel不显示数据

这段代码中,页面加载时,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();
    });
  • 写回答

5条回答 默认 最新

  • works001 2010-08-12 13:38
    关注

    一般来说 tab上加了控件 比方你的tab.add(this.grid);

    之后需要tab.doLayout()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 综合布线实例设计,就好看好看不恐怖可好滤镜好聚
  • ¥15 使用moviepy库视频合并时出错
  • ¥30 FLUENT液固传质UDF
  • ¥15 怎么看梯度直方图以,怎么判断梯度消失/爆炸,怎么解决
  • ¥15 aspnetdll文件访问拒绝
  • ¥15 wpf中在模版中寻找元素
  • ¥15 MFC平台生成指定圆
  • ¥15 jmeter出现403
  • ¥500 求华为P30PRO手机硬盘数据恢复
  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关