Extjs疑难杂症之一

extjs中动态创建的grid,如果需要用到locked属性,一般情况来说是不会生效的。误打误撞之下,在空的columns:[]中加入了一个grid头,就出现了locked头,代码如下:

代码引用

Ext.define('Demo', {
    extend:'Ext.lock.grid.Panel',
    xtype:'Demo',
    border:false,
    columnLines:true,
    requires:[
'App.view.gbps.finance.cashier.ReceivableCashierLayoutCard',
        'App.view.common.DateMonthField'
    ],
    columns: [{locked:true}],
    dockedItems: [{
        xtype:'pagingtoolbar',
        dock:'bottom',
        displayInfo:true
    }, {
        xtype:'toolbar',
        defaults: {
           padding:'5',
            labelAlign:'right'
        },
        items: [{
            xtype:'textfield',
            fieldLabel:'公司名称',
            name:'corpName'
        }, {
        xtype:'textfield',
            fieldLabel:'公司编号',
            name:'corpId'
        }, {
            xtype:'monthfield',
            fieldLabel:'对账单',
            format:'Y-m',
            name:'billDay',
            value:new Date(),
            editable:false
        }, {
            xtype:'button',
            minWidth:80,
            text:'查询',
            handler:'onSearchClick'
        }, {
            xtype:'button',
            minWidth:80,
            text:'重置',
            handler:'onResetClick'
        }]
    }]
});

如上所示,在columns中加入一个{locked: true}就可以了

但是有可能会出现一个错误,提示

Uncaught TypeError: a.setElement is not a function in ext-all.js

解决这个错误的方法是去掉 autoScroll: true这个配置,scrollable: true这个也同样会引起这个报错。

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容