How to set width in Ext.grid.ColumnModel in percentage terms?

Pavlo picture Pavlo · Jul 4, 2010 · Viewed 9.7k times · Source

How to set width in Ext.grid.ColumnModel in percentage terms?

Answer

Robby Pond picture Robby Pond · Jul 4, 2010

Use numbers for the column widths with a total of 100 and configure the view with forceFit, e.g.

var grid = new Ext.grid.GridPanel({
     cm: new Ext.grid.ColumnModel({
          columns: [{
              header: 'header1',
              dataIndex: 'data1',
              width: 30
          },{
              header: 'header2',
              dataIndex: 'data2',
              width: 30
         },{
              header: 'header3',
              dataIndex: 'data3',
              width: 40
         }]
     }),
     viewConfig: {
          forceFit: true
     }
});