weixin_42393259
2010-08-12 11:03
浏览 311

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()

    点赞 评论
  • works001 2010-08-12 11:24

    我一般autoLoad: false, grid的store哪里需要加载时 才去load后台

    对于后一个问题 this.getProcessDefinition 你的这个具体操作没有给出代码

    点赞 评论
  • weibawoaini 2010-08-12 11:31

    Ext的弹出窗口里面的内容好像在火狐下面是不支持的,我以前遇到过,在IE下就正常

    点赞 评论
  • works001 2010-08-12 13:25

    后台的数据 发来看看

    点赞 评论
  • works001 2010-08-12 13:36

    后台的数据格式需要这样的 不知道你的是不?
    {
    resultSet:[{processDefinition:"xxx"},{processDefinition:"xxx2"}]
    }

    点赞 评论

相关推荐 更多相似问题