【发布时间】:2015-04-28 09:52:21
【问题描述】:
我编写了以下 extjs 代码,但是当我添加属性 'width' 和 'height' 时出现错误“无法读取属性 'dom' of null”
但是按钮的大小调整得很好并且表格工作正常,但由于此错误,我的下拉菜单无法正常工作。
有人知道怎么解决吗?
<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>
【问题讨论】:
-
我试过你的代码,它对我来说工作正常。不知道你为什么会遇到这样的问题。
-
我不认为这是因为按钮。 renderTo: 'tab-content' - 你确定 'tab-content' 已定义吗?错误来自那里。
标签: java javascript jquery extjs widget