extjs无法读取属性错误

x6h2sr28  于 2021-07-13  发布在  Java
关注(0)|答案(2)|浏览(380)


我编写了下面的extjs代码,但是当我添加属性width和height时出现错误“cannotreadproperty'dom'ofnull”
不过,按钮的大小调整得很好,表格工作得很好,但是由于这个错误,我的下拉菜单不能正常工作。
有人知道怎么解决吗?

<div id="tab-content">
<script type="text/javascript">
Ext.onReady(function() {
    Ext.create('BVCore.Grid', {
        id:'tab-content',
        renderTo: 'tab-content',
        stateId: 'tab-content',       
        store: Ext.create('BVCore.LocalStore', {
            fields: ['hostName', 'ip', 'serialNumber', 'model', 'role', 'status', 'siteName', 'installDate', 'linkedService'],
            proxy: {
                url:  '<spring:url value="/controller/search/json/deviceSearch.json" />'               
            },
        }),
        features: [{ftype:'grouping'}],
        columns: [
                  {text: '<spring:message code="device.hostname" />', dataIndex: 'hostName', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.ipaddress" />', dataIndex: 'ip', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.sn" />', dataIndex: 'serialNumber', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.model"/>', dataIndex: 'model', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.role" />', dataIndex: 'role', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.status" />', dataIndex: 'status', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.site" />', dataIndex: 'siteName', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.installDate" />', dataIndex: 'installDate', autoSizeColumn: true, align: 'center'},
                  {text: '<spring:message code="device.linkedService" />', dataIndex: 'linkedService', autoSizeColumn: true, align: 'center'},
                  {autoSizeColumn: true, align: 'center', dataIndex: 'id',
                      renderer: function (value, metadata, record) {
                        var id = Ext.id();
                        Ext.defer(function () {
                            Ext.widget('button', {
                                renderTo: id,
                                text: 'Details',
                                width: 75,
                                height: 18,
                                handler: function () {
                                    window.location = "/netmg/controller/home/device/view/" + record.get('id');
                                }
                            });
                        }, 1);
                        return Ext.String.format('<div id="{0}"></div>', id);
                      }
                  }
              ]
    });
});
</script>
</div>
fv2wmkja

fv2wmkja1#

它不是来自按钮配置。错误源于
renderto:'选项卡内容'
在你的代码中,你的网格的id是
'选项卡内容'
并且您正在尝试将相同的元素呈现给您正在创建的元素。确保提供了要将此网格渲染到的正确元素id。如果不是任何元素,那么只分配 renderTo: Ext.getBody() 有关详细信息,请参阅renderto。

zengzsys

zengzsys2#

我发现这个错误要感谢这个帖子:
https://www.sencha.com/forum/showthread.php?246181-typeerror-el-is-null-el-el.dom-ext.getdom(el)-in-ext-all-dev.js-(木质素-19839)

相关问题