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 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现
  • ¥85 永磁型步进电机PID算法