ExtJs grid取到数据而不显示的解决(亲测)
2013-01-12 07:31
417 查看
本文内容使用ExtJs 4.0下亲测通过。刚开始通过网上找的很多方法都不靠谱。
以上是javascript代码,json格式数据从服务器取得,在firefox+firebug中可以看到已经取得数据:
运行代码后,发现已经显示grid,但是没有数据显示。修改成如下代码后正常显示:
1: var store = new Ext.data.JsonStore({
2: url: 'gridData.php',
3: root: 'movies',
4: fields: ['film_id', 'title', 'release_year', 'rating']
5: });
6: var grid = new Ext.grid.GridPanel({
7: title:'Movies',
8: store: store,
9: columns: [
10: { header: "ID", 30, dataIndex: 'film_id',sortable: true, hidden:true },
11: { id: 'title-col', header: "Title", 180,dataIndex: 'title', sortable: true },
12: { header: "Rating", 75, dataIndex: 'rating',sortable: true },
13: { header: "Year", 75, dataIndex: 'release_year',sortable: true, align: 'center' }
14: ],
15: autoExpandColumn: 'title-col',
16: renderTo: Ext.getBody(),
17: 600,
18: height: 300,
19: loadMask: true
20: });
21: store.load();
以上是javascript代码,json格式数据从服务器取得,在firefox+firebug中可以看到已经取得数据:
1: { "count":2, "movies":[{ "film_id":"1", "title":"ACADEMY DINOSAUR", "description":"An Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies", "release_year":"2006", "rating":"PG", "special_features":"Deleted Scenes,Behind the Scenes" }, { "film_id":"2", "title":"ACE GOLDFINGER", "description":"An Astounding Epistle of a Database Administrator And an Explorer who must Find a Car in Ancient China", "release_year":"2006", "rating":"G", "special_features":"Trailers,Deleted Scenes" } ] }
运行代码后,发现已经显示grid,但是没有数据显示。修改成如下代码后正常显示:
1: var store = new Ext.data.JsonStore({
2: proxy: {
3: url: 'gridData.php',
4: type: 'ajax',
5: reader: {
6: type: 'json',
7: root: 'movies'
8: }
9: },
10: fields: ['film_id', 'title', 'release_year', 'rating']
11: });
相关文章推荐
- extjs grid取到数据而不显示的解决
- extjs grid取到数据而不显示的解决
- extjs grid取到数据而不显示的解决
- 解决Extjs的GridPanel在IE6下不显示滚动条问题
- EXTJS Grid数据显示、翻页、增删改查功能实现
- EXTJS Grid数据显示、翻页、增删改查功能实现
- ExtJs actioncolumn根据grid数据动态显示按钮
- EXTJS grid中显示Date timestamp等多种类型改造方法 实用所有数据类型转换
- EXTJS Grid数据显示、翻页、增删改查功能实现
- EXTJS Grid数据显示、翻页、增删改查功能实现
- ExtJS中grid按照使用Expand插件、分组显示、中文拼音首字母排序、改变行背景、列背景、静态数据分页综合案例
- EXTJS Grid数据显示、翻页、增删改查功能实现
- ExtJS两个grid用同一个store显示不同的数据
- Extjs4.2里Grid显示日期类型数据
- Extjs学习------MVC结构的开发(从后台获取数据显示到Grid)
- EXTJS Grid数据显示、翻页、增删改查功能实现
- ExtJs gridPanel 显示查询无数据
- EXTJS Grid数据显示、翻页、增删改查功能实现
- extjs 按条件查询出的数据在grid上不显示
- ExtJs之GridPanel综合操作(一)——异步获取Json数据并显示