EXT数据展示(Ext.grid.Panel)
2015-08-20 17:43
155 查看
在网上看到好多关于EXT的例子,但大多数都是用的EXT代理ajax请求的方式,我这里写的是把EXT与ajax拆开的。下面为EXT代码:
以下为ajax代码:
var dataSource = ''; var myStore = ''; Ext.require([ 'Ext.grid.*', 'Ext.data.*' ]); Ext.onReady(function() { Ext.QuickTips.init();// 标准初始化 // 建立一个store要使用的 model Ext.define('flow_analyse', { extend : 'Ext.data.Model', fields : [ { name : 'count_flow', type : 'int' }, { name : 'first_flow', type : 'int' }, { name : 'last_flow', type : 'int' }] }); myStore = Ext.create('Ext.data.Store', { model : 'flow_analyse', reader: { type: 'json', root: dataSource }, autoLoad : false }); var grid = Ext.create('Ext.grid.Panel', { renderTo : 'information_date',// 渲染到一个div上 frame : true,// 面板渲染 forceFit : true,// 自动填充panel空白处 autoHeight:true, columns : [// 列模式 { text:'序号', xtype: 'rownumberer', width:50, align : 'center'}, { text : "总流量", dataIndex : 'count_flow', width : 100, align : 'center' }, { text : "上行流量", dataIndex : 'first_flow', width : 100, align : 'center' }, { text : "下行流量", dataIndex : 'last_flow', width : 200, align : 'center' }], store : myStore, dockedItems : [ {// 分页 xtype : 'pagingtoolbar', store : myStore, dock : 'bottom',// 定位 displayInfo : true } ] }); /** * 以下是非EXT代码,Ext.onReady(function(){})与$(function(){})具有同样的功能 */ onclickMenu(); //初始化条件区的时间 $('#startDate').datetimebox({ showSeconds:true }); $('#endDate').datetimebox({ showSeconds:true }) });
以下为ajax代码:
function onclickMenu(){ var datas = { }; $.ajax({ type:'post', url:path+'/multipleAnalyseController/selectFlowAnalyse.do', dataType:'json', async: false, data: datas, success:function(result){ myStore.removeAll(); dataSource = result.multipleAnalyseList; myStore.add(dataSource); } }); }
相关文章推荐
- 解决because of many connection errors
- 使用socket方式连接nginx
- Android——Volley学习笔记(二)
- 深入学习RBAC系列模型——RBAC0模型的开发与学习心得
- Struts2的struts.properties文件在哪儿啊?
- 用包容的心态建设卓越团队
- 关于web.xml中不能识别taglib的问题
- hibernate查询——hql查询
- SurfaceView使用实例
- 9.11排序与查找(一)——给定两个排序后的数组A和B,其中A的末端有足够的缓冲空间容纳B。将B合并入A并排序
- ZWEI (zwe)题解
- 百度图片爬虫
- 简单实用SQL脚本
- 在Ubuntu 14.04 64bit上安装StarUML 2.5版本
- centos7 安装 opencv3.0
- Android Studio如何查看、更改JDK和SDK的路径?
- NSFileManager
- mvc注解验证
- HDOJ 确定比赛名次 (拓扑排序)
- 转载于山边小溪的博客--编写跨浏览器兼容的 CSS 代码的金科玉律