Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fit gridPanels columns?

I have application using ExtJs 3.4.
I have this construction:

westPanel-TabPanel:

var westPanel = new Ext.TabPanel({
            id: "west",
            //xtype: "tabpanel",
            //layout:'fit',
            activeTab: 0,
            region: "west",
            border: false,
            width: 278,
            split: true,
            collapseMode: "mini",
            items: [mapList,structure,cadastr,search]
        });

Search - FormPanel:

var search = new Ext.FormPanel({
                labelAlign: 'top',
                frame:true,
                title: 'Поиск',
                bodyStyle:'padding:5px 5px 0',
                //width: 600,
                //layout:'fit',
                items: [{
                    xtype:'textfield',
                    fieldLabel: 'Диспечерское наименование',
                    name: 'name_dispather',
                    anchor:'100%',
                    enableKeyEvents: true,
                    listeners: {
                        'keyup': function(e) {
                            if(e.getValue().length==4){
                                searchStore.load({params:{'name':e.getValue()}});
                            }
                        }
                    }
                },searchTab]
            });

SearchTab - GridPanel:

var searchTab = new Ext.ux.grid.livegrid.GridPanel({
    store: searchStore,
    region: 'center',
    cm: searchCm, 
    layout: 'fit',
    selModel: new Ext.ux.grid.livegrid.RowSelectionModel(),
    stripeRows : true,
    view: myView,
    height: 390,
    loadMask: true,
    id: 'searchTab',
    title:'Найденные объекты',
    autoScroll: true,
});

And i have a problem:

enter image description here

Have to make last column's width to whole panel's width?

UPDATE

I try autoExpandColumn. its works but its not idial:

enter image description here

How to fix it?

like image 805
Kliver Max Avatar asked Jan 16 '13 06:01

Kliver Max


2 Answers

You can achieve this with the flex config.

You can do it on one column only:

columns: [{text: "Column A", dataIndex: "field_A", flex: 1}]

Or you can do it as default on all the columns:

columns: {
    items: [
        {
            text: "Column A"
            dataIndex: "field_A"
        },{
            text: "Column B",
            dataIndex: "field_B"
        }, 
        ...
    ],
    defaults: {
        flex: 1
    }
}
like image 196
A1rPun Avatar answered Oct 23 '22 20:10

A1rPun


Try with:

autoExpandColumn : String

The id of a column in this grid that should expand to fill unused space.

This config option you have to provide for your searchTab (I mean the grid panel).

EDITED:

  viewConfig:{
      scrollOffset: 0,
  forceFit: true
  },

This will remove that gap left for scrollbar. This you need to mention for your searchTab (I mean the grid panel).

like image 4
vajrakumar Avatar answered Oct 23 '22 22:10

vajrakumar