extjs grid 中 ColumnModel 小问题
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"/>
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript" src="extjs/bootstrap.js"></script>
<title>table</title>
<script type="text/javascript">
Ext.onReady(function()
{
var cm =new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id'},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}]);
var data=[
['1','李浩','java软件开发'],
['2','石轩','java软件开发'],
['3','牛雪军','java软件开发'],
['4','赵东磊','java软件开发'],
['5','耿晓庆','平面设计']];
var ds =new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'name'},
{name:'descn'}
])
});
ds.load();
var grid =new Ext.grid.GridPanel({
renderTo:Ext.getBody(),
ds:ds,
cm:cm,
width:300,
autoHeight:true});
});
</script>
</head>
<body>
</body>
</html>
报Ext.grid.ColumnModel is not a constructor 没有构造函数!怎么解决呢 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css"/>
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript" src="extjs/bootstrap.js"></script>
<title>table</title>
<script type="text/javascript">
Ext.onReady(function()
{
var cm =new Ext.grid.ColumnModel([
{header:'编号',dataIndex:'id'},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}]);
var data=[
['1','李浩','java软件开发'],
['2','石轩','java软件开发'],
['3','牛雪军','java软件开发'],
['4','赵东磊','java软件开发'],
['5','耿晓庆','平面设计']];
var ds =new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'name'},
{name:'descn'}
])
});
ds.load();
var grid =new Ext.grid.GridPanel({
renderTo:Ext.getBody(),
ds:ds,
cm:cm,
width:300,
autoHeight:true});
});
</script>
</head>
<body>
</body>
</html>
报Ext.grid.ColumnModel is not a constructor 没有构造函数!怎么解决呢 展开
4个回答
展开全部
var cm = new Ext.grid.ColumnModel({
columns: [{
id: 'common',
header: 'Common Name',
dataIndex: 'common',
width: 220,
// use shorthand alias defined above
editor: new fm.TextField({
allowBlank: false
})
}, {
header: 'Light',
dataIndex: 'light',
width: 130,
editor: new fm.ComboBox({
typeAhead: true,
triggerAction: 'all',
// transform the data already specified in html
transform: 'light',
lazyRender: true,
listClass: 'x-combo-list-small'
})
}, {
header: 'Price',
dataIndex: 'price',
width: 70,
align: 'right',
renderer: 'usMoney',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false,
maxValue: 100000
})
}, {
header: 'Available',
dataIndex: 'availDate',
width: 95,
renderer: formatDate,
editor: new fm.DateField({
format: 'm/d/y',
minValue: '01/01/06',
disabledDays: [0, 6],
disabledDaysText: 'Plants are not available on the weekends'
})
}, {
xtype: 'checkcolumn',
header: 'Indoor?',
dataIndex: 'indoor',
width: 55
}]
});
或者
var colModel = new Ext.grid.ColumnModel([
{ header: "Ticker", width: 60, sortable: true},
{ header: "Company Name", width: 150, sortable: true},
{ header: "Market Cap.", width: 100, sortable: true},
{ header: "$ Sales", width: 100, sortable: true, renderer: money},
{ header: "Employees", width: 100, sortable: true, resizable: false}
]); 注意后面是逗号,不是分号,最后应省略逗号
另外把data部分放外面
var data=[
['1','李浩','java软件开发'],
['2','石轩','java软件开发'],
['3','牛雪军','java软件开发'],
['4','赵东磊','java软件开发'],
['5','耿晓庆','平面设计']];
var ds =new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'name'},
{name:'descn'}
])
});
ds.load();
var grid =new Ext.grid.GridPanel({
renderTo:Ext.getBody(),
ds:ds,
cm:cm,
width:300,
autoHeight:true});
columns: [{
id: 'common',
header: 'Common Name',
dataIndex: 'common',
width: 220,
// use shorthand alias defined above
editor: new fm.TextField({
allowBlank: false
})
}, {
header: 'Light',
dataIndex: 'light',
width: 130,
editor: new fm.ComboBox({
typeAhead: true,
triggerAction: 'all',
// transform the data already specified in html
transform: 'light',
lazyRender: true,
listClass: 'x-combo-list-small'
})
}, {
header: 'Price',
dataIndex: 'price',
width: 70,
align: 'right',
renderer: 'usMoney',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false,
maxValue: 100000
})
}, {
header: 'Available',
dataIndex: 'availDate',
width: 95,
renderer: formatDate,
editor: new fm.DateField({
format: 'm/d/y',
minValue: '01/01/06',
disabledDays: [0, 6],
disabledDaysText: 'Plants are not available on the weekends'
})
}, {
xtype: 'checkcolumn',
header: 'Indoor?',
dataIndex: 'indoor',
width: 55
}]
});
或者
var colModel = new Ext.grid.ColumnModel([
{ header: "Ticker", width: 60, sortable: true},
{ header: "Company Name", width: 150, sortable: true},
{ header: "Market Cap.", width: 100, sortable: true},
{ header: "$ Sales", width: 100, sortable: true, renderer: money},
{ header: "Employees", width: 100, sortable: true, resizable: false}
]); 注意后面是逗号,不是分号,最后应省略逗号
另外把data部分放外面
var data=[
['1','李浩','java软件开发'],
['2','石轩','java软件开发'],
['3','牛雪军','java软件开发'],
['4','赵东磊','java软件开发'],
['5','耿晓庆','平面设计']];
var ds =new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data),
reader:new Ext.data.ArrayReader({},[
{name:'id'},
{name:'name'},
{name:'descn'}
])
});
ds.load();
var grid =new Ext.grid.GridPanel({
renderTo:Ext.getBody(),
ds:ds,
cm:cm,
width:300,
autoHeight:true});
追问
汗、这个和我那个没有区别啊、!
展开全部
比如这么写,这个例子是extjs api 提供的。
Ext.create('Ext.data.Store',{
storeId:'employeeStore',
fields:['firstname','lastname','senority','dep','hired'],
data:[{firstname:"Michael", lastname:"Scott", senority:7, dep:"Manangement",hired:"01/10/2004"},
{firstname:"Dwight", lastname:"Schrute", senority:2, dep:"Sales", hired:"04/01/2004"},{firstname:"Jim", lastname:"Halpert", senority:3, dep:"Sales", hired:"02/22/2006"},
{firstname:"Kevin", lastname:"Malone", senority:4, dep:"Accounting", hired:"06/10/2007"},{firstname:"Angela", lastname:"Martin", senority:5, dep:"Accounting", hired:"10/21/2008"}]});
Ext.create('Ext.grid.Panel',{
title:'Column Demo',
store:Ext.data.StoreManager.lookup('employeeStore'),
columns:[{text:'First Name', dataIndex:'firstname'},
{text:'Last Name', dataIndex:'lastname'},
{text:'Hired Month', dataIndex:'hired', xtype:'datecolumn', format:'M'},
{text:'Department (Yrs)', xtype:'templatecolumn', tpl:'{dep} ({senority})'}],
width:400,
renderTo:Ext.getBody()});
Ext.create('Ext.data.Store',{
storeId:'employeeStore',
fields:['firstname','lastname','senority','dep','hired'],
data:[{firstname:"Michael", lastname:"Scott", senority:7, dep:"Manangement",hired:"01/10/2004"},
{firstname:"Dwight", lastname:"Schrute", senority:2, dep:"Sales", hired:"04/01/2004"},{firstname:"Jim", lastname:"Halpert", senority:3, dep:"Sales", hired:"02/22/2006"},
{firstname:"Kevin", lastname:"Malone", senority:4, dep:"Accounting", hired:"06/10/2007"},{firstname:"Angela", lastname:"Martin", senority:5, dep:"Accounting", hired:"10/21/2008"}]});
Ext.create('Ext.grid.Panel',{
title:'Column Demo',
store:Ext.data.StoreManager.lookup('employeeStore'),
columns:[{text:'First Name', dataIndex:'firstname'},
{text:'Last Name', dataIndex:'lastname'},
{text:'Hired Month', dataIndex:'hired', xtype:'datecolumn', format:'M'},
{text:'Department (Yrs)', xtype:'templatecolumn', tpl:'{dep} ({senority})'}],
width:400,
renderTo:Ext.getBody()});
参考资料: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.column.Column
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1.可以不配置editor 项, 单击单元格时便不可编辑或者手动设置setEditable( Number col, Boolean editable ) 参数分别为行号与是否编辑。
2.正则不灵也许你没监听到那个事件,只能输入数字可以用Ext.form.NumberField 配置相关项可达到目的,只能输入正整数。
2.正则不灵也许你没监听到那个事件,只能输入数字可以用Ext.form.NumberField 配置相关项可达到目的,只能输入正整数。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
前面的ext-base.js和 ext-all.js引进不合适
更多追问追答
追问
要怎么改啊
追答
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询