Morik.Office.DocrecPanel = function(config) {
Morik.Office.DocrecPanel.superclass.constructor.call(this, config);
// 加上服务器上的jsp数据生成
// 生成Company类型
var proxy = new Ext.data.HttpProxy( {
url : 'company.jsp'
});
var recordType = new Ext.data.Record.create([ {
name : "id",
type : "int"
},{
name:"date",
type:"date"
}, {
name : "name",
type : "string"
}, {
name : "add",
type : "string"
}, {
name : "tel",
type : "string"
},{
name:'indoor',
type:'bool'
}]);
var reader = new Ext.data.JsonReader( {
totalProperty : "results",
root : "rows",
id : "id"
}, recordType);
//
// // 定义store
var store = new Ext.data.Store( {
proxy : proxy,
reader : reader
});
this.store=store;
// 第二,讲一下cm,grid
var fm = Ext.form;
[color=red] var checkColumn = new Ext.grid.CheckColumn ({
header: "Indoor?",
dataIndex: 'indoor',
width: 55
});[/color]
function formatDate(value){
return value ? value.dateFormat('M d, Y') : '';
};
var cm = new Ext.grid.ColumnModel( {
defaultSortable : true,
defaultWidth : 100,
columns : [ {
header : '编号',
dataIndex : 'id'
}, {
header:'日期',
dateIndex:'date',
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'
})
},{
header : '名称',
dataIndex : 'name',
editor: new fm.TextField({
allowBlank: false
})
}, {
header : '地址',
width : 300,
dataIndex : 'add',
editor: new fm.TextField({
allowBlank: false
})
}, {
header : '电话',
width : 300,
dataIndex : 'tel',
editor: new fm.NumberField({
allowBlank: false,
allowNegative: false,
maxValue: 100000
})
}
]
});
var Plant = Ext.data.Record.create([
// the "name" below matches the tag name to read, except "availDate"
// which is mapped to the tag "availability"
{name: 'id', type: 'string'},
{name: 'date', mapping: 'availability', type: 'date', dateFormat: 'm/d/Y'},
{name: 'name'},
{name: 'add', type: 'float'}, // automatic date conversions
{name: 'tel', type: 'string'},
{name: 'indoor', type: 'bool'}
]);
var grid = new Ext.grid.EditorGridPanel( {
cm : cm,
store : store,
width : 1000,
height : 400,
autoExpandColumn:'common',
// title:'Edit Plants?',
// frame:true,
plugins:checkColumn,
clicksToEdit:1,
tbar:[{ text: 'Add Plant',
handler : function(){
var p = new Plant({
id: 'New Plant 1',
date:'',
name:'',
add: 'Mostly Shade',
tel: 0,
availDate: (new Date()).clearTime(),
indoor:false
});
grid.stopEditing();
store.insert(0, p);
grid.startEditing(0, 0);
}}],
loadMask:{msg:'正在载入数据,请稍等...'},
title : '公司列表'
});
// trigger the data store load
store.load();
this.add(grid);
// 第三、调整,tbar分页,工具栏
var checkColumn = new Ext.grid.CheckColumn();
Ext.grid.CheckColumn = function(config){
Ext.apply(this, config);
if(!this.id){
this.id = Ext.id();
}
this.renderer = this.renderer.createDelegate(this);
};
Ext.grid.CheckColumn.prototype ={
init : function(grid){
this.grid = grid;
this.grid.on('render', function(){
var view = this.grid.getView();
view.mainBody.on('mousedown', this.onMouseDown, this);
}, this);
},
onMouseDown : function(e, t){
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
e.stopEvent();
var index = this.grid.getView().findRowIndex(t);
var record = this.grid.store.getAt(index);
record.set(this.dataIndex, !record.data[this.dataIndex]);
}
}
};
}
Ext.extend(Morik.Office.DocrecPanel, Ext.Panel, {});
出错提示代码为红色标注的这段 提示为图片所示,求各位帮忙找一下错误原因 ,3Q
[b]问题补充:[/b]
TO:lovewhzlq (架构师)
按照你的写法,提示出错信息依然存在 ,且为同一错误信息,郁闷了
[b]问题补充:[/b]
TO:lovewhzlq 因为EXTJS是新上手 所以很多代码不是自己写的
var checkColumn = new Ext.grid.CheckColumn();
Ext.grid.CheckColumn = function(config){
Ext.apply(this, config);
if(!this.id){
this.id = Ext.id();
}
this.renderer = this.renderer.createDelegate(this);
};
Ext.grid.CheckColumn.prototype ={
init : function(grid){
this.grid = grid;
this.grid.on('render', function(){
var view = this.grid.getView();
view.mainBody.on('mousedown', this.onMouseDown, this);
}, this);
},
onMouseDown : function(e, t){
if(t.className && t.className.indexOf('x-grid3-cc-'+this.id) != -1){
e.stopEvent();
var index = this.grid.getView().findRowIndex(t);
var record = this.grid.store.getAt(index);
record.set(this.dataIndex, !record.data[this.dataIndex]);
}
}
};
这段代码就是从ext-js的范例里拿过来的 感觉是错在这里 跟上面的代码连续不上
[b]问题补充:[/b]
TO yourgame
我没用firefox 我用的是IE的插件调试的 结果差不多的吧
[b]问题补充:[/b]
TO yourgame 你给我的代码调试出来报错信息如下图所示,点击进去看到的是ext-all-debug.js里面的一段代码 ,不过想想是不会这个JS里面的错误
后来自己调试了下发现是autoExpandColumn : 'common',这段代码出的错 将这段代码注释掉后就正常 无报错了 PS:这个JS是点击左侧tree时所调用到的,装载到右边tabpanel中的代码