Extjs毕业设计:在做分页查询产品信息时,出现TypeError: this.ds is undefined?
2014-04-15 00:00
176 查看
分析:this.ds is undefined? 说明:ds--> datastore 说明是 store那出问题了。
我的productlist.js代码如下:
Ext.onReady(function(){
Ext.QuickTips.init();//浮动信息提示,启动悬停提示
Ext.BLANK_IMAGE_URL = "../../scripts/extjs/resources/images/default/s.gif";//替换图片文件地址为本地
//获取数据源,该方法返回一个json格式的数据源,同一个域里边用HttpProxy ; 跨域用ScriptTagProxy
var proxy = new Ext.data.HttpProxy({
url : 'getAllProduct.action'
});
//定义reader,读取数据源用json方法(三种方法:1 读取json 用JsonReader;2.读取数组使用ArrayReader 3.读取XML用XmlReader )
var reader = new Ext.data.JsonReader({
totalProperty:'totalCount',//从数据库中读取的总记录数
root: 'jsonarray'
},[
{name: 'id'}, //读取处理的字段
{name: 'name'},
{name: 'ptype'},
{name: 'batch'},
{name: 'unit'},
{name: 'price'},
{name: 'memo'}
]);
//构建Store,读取数据,Json格式
var store = new Ext.data.Store({
proxy : proxy,
reader : reader
});
//加载
store.load({params:{start:0, limit:10}});
var sm = new Ext.grid.CheckboxSelectionModel();
// create the Grid
var grid = new Ext.grid.GridPanel({
store:store,
columns: [
new Ext.grid.RowNumberer(),
sm,
{header: "ID", width: 75, sortable: true, dataIndex: 'id'},
{header: "名称", width: 75, sortable: true, dataIndex: 'name'},
{header: "型号", width: 75, sortable: true, dataIndex: 'ptype'},
{header: "等级/批次", width: 75, sortable: true, dataIndex: 'batch'},
{header: "单位", width: 85, sortable: true, dataIndex: 'unit'},
{header: "单价", width: 85, sortable: true, dataIndex: 'price'},
{header: "备注", width: 85, sortable: true, dataIndex: 'memo'}
],
stripeRows: true,
// autoExpandColumn: 'company',
bodyStyle:'width:100%',
height:425,
loadMask:{msg:'数据加载中,请稍后...'},//出现loading图标
frame:true,
title:'当前位置>基础数据管理>产品查询>产品列表',
plugins: new Ext.ux.PanelResizer({
minHeight: 100
}),
//分页工具条
bbar: new Ext.PagingToolbar({
pageSize: 10, //每页的记录数
//store: store, //开始这个地方没有,所以报错ds is undefined? 注释掉注释 就搞定了。
displayInfo: true, //是否显示displayMsg 默认是不显示
displayMsg:"<span style='font-sytle:italic;'>当前显示从{0}条到{1}条,共{2}条</span>",
emptyMsg:"<span style='color:red;font-sytle:italic;'>没有数据</span>", //没有记录时显示的文本,
plugins: new Ext.ux.ProgressBarPager()
})
});
grid.render('grid-product');
//
});
总结:
处理这store 没有显示的问题需要考虑下面几条:
1. Validate that the URL is accessible ,(验证你的URL是 有效的,比如这里我的url:getAllProduct.action ,在服务器端 打断点,能进入debug模式,说明这条我符合)
2. Make sure that data is really coming that from the URL.(确认你的数据真的从URL传递到前台来了,这里我通过 firefox 的响应 能看到我传递过来的json格式的数据,符合)
3. Is your data in valid formate for extjs?(验证你的数据和extjs格式匹配,这里我对比po类中的字段,检查extjs中的字段,符合,说明是我extjs中的属性没添加,见红色注释部分)
如图:
我的productlist.js代码如下:
Ext.onReady(function(){
Ext.QuickTips.init();//浮动信息提示,启动悬停提示
Ext.BLANK_IMAGE_URL = "../../scripts/extjs/resources/images/default/s.gif";//替换图片文件地址为本地
//获取数据源,该方法返回一个json格式的数据源,同一个域里边用HttpProxy ; 跨域用ScriptTagProxy
var proxy = new Ext.data.HttpProxy({
url : 'getAllProduct.action'
});
//定义reader,读取数据源用json方法(三种方法:1 读取json 用JsonReader;2.读取数组使用ArrayReader 3.读取XML用XmlReader )
var reader = new Ext.data.JsonReader({
totalProperty:'totalCount',//从数据库中读取的总记录数
root: 'jsonarray'
},[
{name: 'id'}, //读取处理的字段
{name: 'name'},
{name: 'ptype'},
{name: 'batch'},
{name: 'unit'},
{name: 'price'},
{name: 'memo'}
]);
//构建Store,读取数据,Json格式
var store = new Ext.data.Store({
proxy : proxy,
reader : reader
});
//加载
store.load({params:{start:0, limit:10}});
var sm = new Ext.grid.CheckboxSelectionModel();
// create the Grid
var grid = new Ext.grid.GridPanel({
store:store,
columns: [
new Ext.grid.RowNumberer(),
sm,
{header: "ID", width: 75, sortable: true, dataIndex: 'id'},
{header: "名称", width: 75, sortable: true, dataIndex: 'name'},
{header: "型号", width: 75, sortable: true, dataIndex: 'ptype'},
{header: "等级/批次", width: 75, sortable: true, dataIndex: 'batch'},
{header: "单位", width: 85, sortable: true, dataIndex: 'unit'},
{header: "单价", width: 85, sortable: true, dataIndex: 'price'},
{header: "备注", width: 85, sortable: true, dataIndex: 'memo'}
],
stripeRows: true,
// autoExpandColumn: 'company',
bodyStyle:'width:100%',
height:425,
loadMask:{msg:'数据加载中,请稍后...'},//出现loading图标
frame:true,
title:'当前位置>基础数据管理>产品查询>产品列表',
plugins: new Ext.ux.PanelResizer({
minHeight: 100
}),
//分页工具条
bbar: new Ext.PagingToolbar({
pageSize: 10, //每页的记录数
//store: store, //开始这个地方没有,所以报错ds is undefined? 注释掉注释 就搞定了。
displayInfo: true, //是否显示displayMsg 默认是不显示
displayMsg:"<span style='font-sytle:italic;'>当前显示从{0}条到{1}条,共{2}条</span>",
emptyMsg:"<span style='color:red;font-sytle:italic;'>没有数据</span>", //没有记录时显示的文本,
plugins: new Ext.ux.ProgressBarPager()
})
});
grid.render('grid-product');
//
});
总结:
处理这store 没有显示的问题需要考虑下面几条:
1. Validate that the URL is accessible ,(验证你的URL是 有效的,比如这里我的url:getAllProduct.action ,在服务器端 打断点,能进入debug模式,说明这条我符合)
2. Make sure that data is really coming that from the URL.(确认你的数据真的从URL传递到前台来了,这里我通过 firefox 的响应 能看到我传递过来的json格式的数据,符合)
3. Is your data in valid formate for extjs?(验证你的数据和extjs格式匹配,这里我对比po类中的字段,检查extjs中的字段,符合,说明是我extjs中的属性没添加,见红色注释部分)
如图:
相关文章推荐
- 查询脚本jquery出错:TypeError: rows is undefined
- 出现TypeError: 'undefined' is not a function (evaluating '$')错误
- TypeError:this.K is undefined
- 使用jquery插件autocomplete时候出现typeerror:this.source is not a function即与jquery的autocomplete冲突
- 在使用jQuery2.1.0和bootstrap2.3.2出现“TypeError: $.browser is undefined”错误的解决方法
- JS报错 Uncaught TypeError: undefined is not a function,解决
- js Uncaught TypeError: undefined is not a function
- FCKeditor关于图片上传出现错误“ 提示没有权限 Type=Image” 以及出现"this connector is disabled Please check the"editor/filemanager/connectors/aspx/conf
- this.ds is undefined
- 如何解决TypeError: d3.scale is undefined
- TypeError: elem.nodeName is undefined
- echarts中地图提示"TypeError:i is undefined"
- Sea.js出现Uncaught TypeError: object is not a function
- Matlab出现On Startup: Error using eval undefined function 'workspacefunc' for input arguments of type
- this.ds is undefined
- 在使用JQuery插件时报错:TypeError:$.browser is undefined的解决方法
- echarts中地图提示"TypeError:i is undefined"
- eclipse中NodeList出现The method getTextContent() is undefined for the type Node
- React native:TypeError: undefined is not a function (evaluating 'addListener')
- this.ds is undefined