开发者

ExtJS EditorGridPanel display Error

I have a problem with a Ext.Grid.EditorGridPanel, I am currently using ExtJS 2.3.0, that can't be changed. :-(

Following the problem:

I created a window which consist of 2 FormPanel and between them the EditorGridPanel. For the viewConfig of the grid, there is only "forceFit=true" set and no style or view options set for the ColumnModel. Only for each column the align option is set to "center". The ColumnModel consits of 13 columns, more or less text only. Now I open the website I am working on with a browser and open the window to test the GUI. When I try to switch between the cells in a single row the entire data row moves to the left, so that the first cells are no more shown. After adding a new row to the grid (via an add button) the view resets and all cells for each column are displayed correctly again. The column headers and the tbar are fixed and always correctly rendered.

The problem occurs with IExplorer 8.0x, an older Firefox version (2.0x), but the grid works fine with Firefox 3.6x and Safari 5.0x. If someone had a similar problem and got it fixed or an idea what may causes that problem, feel free to answer. ;-) Many thanks in advance!

[edit] Thx for comment, here some modifyed Source from the complete Source:

getTypeSelectionGrid: function() {
    this.gridRecord:  Ext.data.Record.create([
        {name:'id', type:'int'},
        {name:'start', type:'string'},
        {name:'end', type:'string'},
        {name:'mo', type:'boolean'},
        {name:'tu', type:'boolean'},
        {name:'we', type:'boolean'},
        {name:'th', type:'boolean'},
        {name:'fr', type:'boolean'},
        {name:'sa', type:'boolean'},
        {name:'su', type:'boolean'},
        {name:'type', type:'string'}
    ]);

    this.gridStore = new Ext.data.Store({
        baseParams: {
        },
        sortInfo: {field: 'id', direction: 'ASC'},
        proxy: new Ext.data.HttpProxy({
            url: '',
            method: 'post'
        }),
        reader: new Ext.data.JsonReader({
            root: 'data',
            totalProperty: 'totalCount',
            id: 'id'
        }, this.gridRecord)
    });

    var sm = new Ext.grid.RowSelectionModel({ singleSelect: true });

    var columnConfig = [];
    //auto incremented id column
    columnConfig.push({ 
        header: 'id',
        dataIndex: 'id',
        width: 50,
        editor: new Ext.form.TextField({
            anchor: '100%',
            allowBlank: false,
            disabled: true
        })
    });
    //start value for time range, values from '00:00' to '24:00' steps by second, here shorted to 2 options
    columnConfig.push({
        header: 'start',
        dataIndex: 'start',
        width: 70,
        align: 'center',
        editor: new Ext.form.ComboBox({
            store: new Ext.data.SimpleStore({
                fields: ['val', 'txt'],
                data : [['00:00', '00:00'],['24:00', '24:00']]
            }),
            displayField: 'txt',
            valueField: 'val',
            typeAhead: true,
            mode: 'local',
            triggerAction: 'all',
            selectOnFocus: true,
            saveRouting: true,
            forceSelection: true,
            anchor: '100%',
            allowBlank: false
        })
    });
    //same as above for end of time range, dataIndex 'end'

    //now 7 checkbox columns foreach weekday
    columnConfig.push({
        xtype: 'checkcolumn',
        header: 'mo',
        dataIndex: 'mo',
        align: 'center',
        width: 30
    }));
    //same as above for dataIndex 'tu', 'we', 'th', 'fr', 'sa' and 'su'

    //here simplified to SimpleStore, originally a remote store which gets the data
    //by a HttpProxy
    columnConfig.push({
        header: 'type',
        dataIndex: 'type',
        editor: new Ext.form.ComboBox({
            store: new Ext.data.SimpleStore({
                fields: ['val', 'txt'],
                data : [[1, 'type 1'],[2, 'type 2']]
            }),
            displayField: 'txt',
            valueField: 'txt',
            typeAhead: true,
            mode: 'local',
            triggerAction: 'all',
            selectOnFocus: true,
            saveRouting: true,
            forceSelection: true,
            anchor: '100%',
            allowBlank: false
        })
    });
    //then 2 plugins which have some functionality for the selected row
    //grid tested with and without both plugins, they are not the cause

    var cm = new Ext.grid.ColumnModel(columnConfig);
    cm.defaultSortable = false;

    //now the grid
    this.typeSelectionGrid = new Ext.grid.EditorGridPanel({
        store: this.gridStore,
        clicksToEdit: 1,
        autoHeight: true,
        cm: cm,
        sm: sm,
        viewConfig: {
            forceFit: true
        },
        tbar: [{
            text: 'add new row',
            cls: 'x-btn-text',
            scope: this,
            handler: function(){
                //adds a row with incremented id
            }
        }],
        listeners: {
            scope: this,
            show: function() {
                sm.selectFirstRow.defer(1000, selectionModel);
            }
        }
    });

    return this.typeSelectionGrid;
},

//the grid is then inserted between the Panels into the window component
//looks something like that
render: function() {

    var layoutFn = function(pnl) {
        pnl.ownerCt.ownerCt.doLayout.defer(Ext.isIE ? 300 : 0, pnl.ownerCt.ownerCt);
        pnl.doLayout.defer(Ext.isIE ? 500 : 200, pnl);
    };
    this.cardLayout.add({
        layout: 'border',
        border: false,
        bodyStyle: 'background-color: #fff',
        items: [
            {
                region: 'center',
                border: false,
                layout: 'column',
                autoScroll: true,
                defaults: {
                    columnWidth: 1,
                    bodyStyle: 'padding: 5px;',
                    border: false,
                    autoHeight: true,
                    layout: 'column',
                    defaults: {
                        columnWidth: 1
                    }
                },
                items: [
                    //first Ext.form.FormPanel with some TextFields
                    {
                        items: {
                            listeners: {
                                expand: layoutFn,
                  开发者_如何学JAVA              collapse: layoutFn
                            },
                            frame: true,
                            title: 'panel with a grid',
                            collapsible: true,
                            titleCollapse: true,
                            layout: 'fit',
                            autoHeight: true,
                            items: this.getTypeSelectionGrid()
                        }
                    }
                    //second Ext.form.FormPanel with some TextFields
                ]
            }
        ]
    });
}


First of all, it looks like you have some JavaScript syntax errors. I know you only posted a snippet of your code, but try running the whole thing through JS Lint.

For starters:

this.gridRecord:  Ext.data.Record.create([
    {name:'id', type:'int'},
    {name:'start', type:'string'},
    {name:'end', type:'string'},
    {name:'mo', type:'boolean'},
    {name:'tu', type:'boolean'},
    {name:'we', type:'boolean'},
    {name:'th', type:'boolean'},
    {name:'fr', type:'boolean'},
    {name:'sa', type:'boolean'},
    {name:'su', type:'boolean'},
    {name:'type', type:'string'}
]);

Should be:

this.gridRecord = Ext.data.Record.create([

While I'm not entirely sure this would cause the problem, I see that your column configs have widths assigned to them. Even though you are setting the viewConfig property "forceFit: true", I suspect that the editor may attempt to use the widths you have set for each column.

See if that clears up anything.


Thanks, but the code snippet has a copy and paste error, the gridRecord is a global property at the original code. I overlooked that as i modified the code, sorry for the confusion.

Now I tried your suggestion and found the culprit: It seems like IE can't handle the "forceFit" option at all, I commented out that option and set the width for each column and... it worked fine, no column moves! No I inserted a work around, first I check if the browser is an IE if not the "forceFit" option is set to "true" else "false".

Many thanks for your help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜