【问题标题】:ExtJS Gridpanel Column width + forcefitExtJS Gridpanel 列宽 + forcefit
【发布时间】:2011-12-15 16:50:45
【问题描述】:

我有一个网格面板,我想在其中包含 2 列。我希望第一列的宽度为 100,第二列填充网格面板中的剩余宽度。

有什么想法吗?

编辑

sensorListPanel = new xg.GridPanel({
    id: 'sensorListPanel',
    region: 'west',
    width: 415,
    viewConfig: {
        forceFit:true,
        //fitcontainer:true
    },
    store: sensorStore,
    cm: new xg.ColumnModel({
        defaults: {
            width: 120,
            sortable: true
        },
        columns: [
            smSensors,
            {id:'Station',header: "Station", width: 95, dataIndex: 'gml_id'},
            {id:'Description', header: "Description", dataIndex: 'description'}
        ]
    }),
    sm: smSensors,
    columnLines: true,
    title:'Sensors',
});

【问题讨论】:

    标签: extjs width gridpanel


    【解决方案1】:

    尝试在 viewconfig 中设置 forceFit

    viewConfig:{forceFit:true}
    

    通过指定 forceFit:true,非固定宽度的列将被重新分配(基于相对初始宽度)以填充网格的宽度。

    【讨论】:

    • 当我这样做时,列被分成 2 列并均匀分布。请查看我刚刚发布的代码。谢谢!!!
    • 从列模型的默认配置中移除宽度
    • 你好 MMT,我在框架版本 5.0.1 中尝试但不工作
    【解决方案2】:

    您可以使用 Grid 上的“autoExpandColumn”配置。

    {
        xtype : 'grid',
    
        cm : //Your Column model Code,
    
        autoExpandColumn : COLUMN_NAME_FROM_COLUMN_MODEL
    }
    

    在列模型中,您可以为固定宽度的列指定宽度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多