在ext的grid中 当设置每一列的sortable=ture时,在gridpanel的页面上就可以对
 每一列进行重排,例如:每一列右边的下拉框,下columns对应的列,选中后可以让
 每一列显示或隐藏。如:
                    columns--->“名称”
                           --->“大小”
                           --->"时间"
 问题:
    1、 当全部让它们隐藏的时候,问什么会报“参数无效” 原因在这一行:ext-bug.js
       
     this.getHeaderCell(i).style.width = widths[i]; 查看了一下其中i对应的值是无穷大,
     
     请问有什么办法解决吗?急急急!!!!
   2、当重新选择后,(即对列隐藏后又显示)列的宽度样式,为什么会发生变化?    
                        
             
   

解决方案 »

  1.   

    不隐藏的时候第一个问题没有出现么?你的那段代码是在哪定义的?
    第二个 你给columns每一列设置一个百分比宽度即可
      

  2.   

    不隐藏的时候是不会出现这样的问题的 就是当全部隐藏,隐藏到最后一个的时候出现这样的错误的。 代码的定义是这:    _initColumn : function (){
             var cols = [
                {
                    id : "taskTitle",
                    header : "标题",
                    width : 300,
                    dataIndex : "title",
                    id : "task-title"
                },
                {
                    header    : "任务类型",
                    width     : 100,
                    dataIndex : "taskType"
                },
                {
                    header : "主办人",
                    width : 100,
                    dataIndex: 'processor'
                },
                  {
                    header   : "处理人",
                    width    : 100, 
                    dataIndex: "handler",
                    renderer : function(v){
                        return "xxxx"+v+"xxx";
                    }
                },
                 {
                    header       : "状态",
                    width       : 100,
                    dataIndex : "status"
                },
                {
                    header : "计划开始",
                    width : 100,
                    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
                    dataIndex : "scheduleBegin"
                },
                {
                    header : "计划结束",
                    width : 100,
                    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
                    dataIndex : "scheduleEnd"
                },
                {
                    header : "实际开始",
                    width : 100,
                    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
                    dataIndex : "actuallyBegin"
                },
                {
                    header : "实际结束",
                    width : 100,
                    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
                    dataIndex : "actuallyEnd"
                }
            ];
        }
          
           var  columns=this._initColumn();
            var defaultConfig = {
                id : "task-list-of-this-week",        //唯一ID
                store : taskStore,
                height : 500,
                viewConfig : gridView,
                closable : true,
                columns : columns,
                autoExpandColumn : "taskTitle"
            }  大致就是这样store是正确的这个可以放心
     
      

  3.   

    从新选择 columns 触发的是什么事件?
      

  4.   

    _initColumn : function()
    {
    var cols = [{
    id : "taskTitle",
    header : "标题",
    width : 300,
    dataIndex : "title",
    id : "task-title"
    }, {
    header : "任务类型",
    width : 100,
    dataIndex : "taskType"
    }, {
    header : "主办人",
    width : 100,
    dataIndex : 'processor'
    }, {
    header : "处理人",
    width : 100,
    dataIndex : "handler",
    renderer : function(v)
    {
    return "xxxx" + v + "xxx";
    }
    }, {
    header : "状态",
    width : 100,
    dataIndex : "status"
    }, {
    header : "计划开始",
    width : 100,
    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
    dataIndex : "scheduleBegin"
    }, {
    header : "计划结束",
    width : 100,
    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
    dataIndex : "scheduleEnd"
    }, {
    header : "实际开始",
    width : 100,
    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
    dataIndex : "actuallyBegin"
    }, {
    header : "实际结束",
    width : 100,
    renderer : Ext.util.Format.dateRenderer('Y-m-d'),
    dataIndex : "actuallyEnd"
    }];
    return cols; }