最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - How to fit gridPanels columns? - Stack Overflow

matteradmin4PV0评论

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:

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

UPDATE

I try autoExpandColumn. its works but its not idial:

How to fix it?

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:

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

UPDATE

I try autoExpandColumn. its works but its not idial:

How to fix it?

Share Improve this question edited Jan 17, 2013 at 6:34 Kliver Max asked Jan 16, 2013 at 6:39 Kliver MaxKliver Max 5,30924 gold badges101 silver badges157 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

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
    }
}

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

Post a comment

comment list (0)

  1. No comments so far