SCRIPT5007: 无法获取属性“clientWidth”的值: 对象为 null 或未定义解决方案
SCRIPT5007: 无法获取属性“clientWidth”的值: 对象为 null 或未定义
用容器出错啊
------解决思路----------------------
你这个写法似乎不是全兼容的
参考一下这里:http://www.w3school.com.cn/js/js_window.asp
var colModel = new Ext.grid.ColumnModel
(
[
new Ext.grid.RowNumberer(),
{ header: "入库日期", sortable: true, resizable: true, dataIndex: 'in_date', width: 120 },
{ header: "名称", sortable: true, resizable: true, dataIndex: 'name', width: 120 },
{ header: "厂家", sortable: true, resizable: true, dataIndex: 'manu_name', width: 100 },
{ header: "规格", sortable: true, resizable: true, dataIndex: 'spe_type', width: 100 },
{ header: "单位", sortable: true, resizable: true, dataIndex: 'j_name', width: 50 },
{ header: "数量", sortable: true, resizable: true, dataIndex: 'numeral', width: 50 },
{ header: "入库单价", sortable: true, resizable: true, dataIndex: 'in_price', width: 50 },
{ header: "价格", sortable: true, resizable: true, dataIndex: 'price', width: 80 },
{ header: "金额", sortable: true, resizable: true, dataIndex: 'in_value', width: 70 },
{ header: "供应商", sortable: true, resizable: true, dataIndex: 'source', width: 100 },
{ header: "批号", sortable: true, resizable: true, dataIndex: 'lot_no', width: 100 },
{ header: "单号", sortable: true, resizable: true, dataIndex: 'in_docu', width: 100 },
{ header: "序号", sortable: true, resizable: true, dataIndex: 'item_no', width: 40 },
{ header: "属性", sortable: true, resizable: true, dataIndex: 'property_name', width: 140 },
{ header: "分类名称", sortable: true, resizable: true, dataIndex: 'group_name', width: 140 },
{ header: "备注", sortable: true, resizable: true, dataIndex: 'abstract', width: 100 }
]
);
var date = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '/josn/select/select_warehousing.aspx'
}),
reader: new Ext.data.JsonReader({
root: 'data',
totalProperty: 'totalProperty'
}, [
{ name: 'code', type: 'string' },
{ name: 'in_date', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'manu_name', type: 'string' },
{ name: 'spe_type', type: 'string' },
{ name: 'j_name', type: 'string' },
{ name: 'numeral', type: 'string' },
{ name: 'in_price', type: 'string' },
{ name: 'price', type: 'string' },
{ name: 'in_value', type: 'string' },
{ name: 'source', type: 'string' },
{ name: 'lot_no', type: 'string' },
{ name: 'in_docu', type: 'string' },
{ name: 'item_no', type: 'string' },
{ name: 'property_name', type: 'string' },
{ name: 'group_name', type: 'string' },
{ name: 'abstract', type: 'string' }
]),
remoteSort: true
});
date.setDefaultSort('code', 'in_date', 'name', 'spe_type', 'j_name', 'numeral', 'in_price', 'price', 'in_value', 'source', 'lot_no', 'in_docu', 'item_no', 'property_name', 'group_name', 'abstract');
date.load({ params: { name: ""} });
var pagingToolbar = new Ext.PagingToolbar(
{
//显示每页多少条数据
store: date,
pageSize: 30,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条物品信息',
emptyMsg: "没有记录"
});
var orgGrid = Ext.get("XWARE1"); //展示grid的容器
var grid = new Ext.grid.GridPanel
(
{
id: 'grid_P',
renderTo: 'XWARE1',
//IE这个很重要要写el:‘要渲染的div’
// width: document.body.offsetWidth,
// height: document.body.offsetHeight - 70,
width: document.body.clientWidth,
height: document.body.clientHeight - 70,
// width: orgGrid.getComputedWidth(),
// height: orgGrid.getComputedHeight() ,
layout: 'fit',
AutoHeight: true,
AutoWidth: true,
monitorResize: true,
cm: colModel, //行列
store: date, //数据源
bbar: pagingToolbar,
trackMouseOver: true, //鼠标特效
loadMask: true, //灰色盖住的效果
autoShow: true,
autoScroll: true
}
);
grid.render(orgGrid); //把grid铺到id为orgGrid的容器中
window.onresize = function () {
grid.setWidth(0);
grid.setHeight(0);
// grid.setHeight(document.body.offsetHeight - 60);
// grid.setWidth(document.body.offsetWidth);
// grid.setHeight(orgGrid.getComputedHeight() - 60);
// grid.setWidth(orgGrid.getComputedWidth());
};
用容器出错啊
------解决思路----------------------
你这个写法似乎不是全兼容的
参考一下这里:http://www.w3school.com.cn/js/js_window.asp