Java Extjs无法读取属性错误

Java Extjs无法读取属性错误,java,javascript,jquery,extjs,widget,Java,Javascript,Jquery,Extjs,Widget,我编写了以下extjs代码,但在添加属性“width”和“height”时出现错误“无法读取null的属性“dom” 但是,按钮的大小调整得很好,表格工作正常,但导致此错误的原因是我的下拉菜单无法正常工作 有人知道怎么解决吗 <div id="tab-content"> <script type="text/javascript"> Ext.onReady(function() { Ext.create('BVCore.Grid', { id:'t

我编写了以下extjs代码,但在添加属性“width”和“height”时出现错误“无法读取null的属性“dom”
但是,按钮的大小调整得很好,表格工作正常,但导致此错误的原因是我的下拉菜单无法正常工作

有人知道怎么解决吗

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

Ext.onReady(函数(){
Ext.create('BVCore.Grid'{
id:'tab-content',
renderTo:“选项卡内容”,
stateId:“选项卡内容”,
store:Ext.create('BVCore.LocalStore'{
字段:[“主机名”、“ip”、“序列号”、“型号”、“角色”、“状态”、“站点名”、“安装日期”、“linkedService”],
代理:{
url:“”
},
}),
功能:[{ftype:'grouping'}],
栏目:[
{text:'',dataIndex:'hostName',autoSizeColumn:true,align:'center'},
{text:'',dataIndex:'ip',autoSizeColumn:true,align:'center'},
{文本:'',数据索引:'serialNumber',autoSizeColumn:true,对齐:'center'},
{text:'',dataIndex:'model',autoSizeColumn:true,align:'center'},
{text:'',dataIndex:'role',autoSizeColumn:true,align:'center'},
{text:'',dataIndex:'status',autoSizeColumn:true,align:'center'},
{text:'',dataIndex:'siteName',autoSizeColumn:true,align:'center'},
{文本:'',数据索引:'installDate',autoSizeColumn:true,对齐:'center'},
{文本:'',数据索引:'linkedService',autoSizeColumn:true,对齐:'center'},
{autoSizeColumn:true,align:'center',dataIndex:'id',
渲染器:函数(值、元数据、记录){
var id=Ext.id();
Ext.defer(函数(){
Ext.widget('按钮'{
renderTo:id,
文本:“详细信息”,
宽度:75,
身高:18,
处理程序:函数(){
window.location=“/netmg/controller/home/device/view/”+record.get('id');
}
});
}, 1);
返回Ext.String.format(“”,id);
}
}
]
});
});

它不是来自按钮配置。 错误来自于

renderTo:“选项卡内容”

在您的代码中,网格的id是

“选项卡内容”

您正在尝试将相同的元素渲染到您正在创建的元素。 确保提供了要渲染此网格的正确元素id。如果没有指定给任何元素,则只指定

renderTo:Ext.getBody()


有关更多信息,请参阅

多亏了这篇文章,我发现了这个错误:


我尝试了你的代码,它对我来说运行良好。我不知道你为什么会面临这样的问题。我不认为这是因为按钮。renderTo:“选项卡内容”-您确定已定义“选项卡内容”吗?错误来自那里。我编辑了我的描述,选项卡内容是define。我想把网格放在这个分区中,我读了文档,上面写着“如果组件是容器的子项,请不要使用此选项。容器的布局管理器负责呈现和管理其子项。”但是当我不使用renderTo表disappear时,我看不到任何异常。请确保网格的id与div的id也不同。“BVCore.Grid”是否有任何自定义更改?你能分享代码吗?看看这个小提琴-。检查index.html文件。app.js文件为空,是否特定于浏览器?