EXT数据展示(Ext.grid.Panel)

在网上看到好多关于EXT的例子,但大多数都是用的EXT代理ajax请求的方式,我这里写的是把EXT与ajax拆开的。下面为EXT代码:
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);
		}    
	});
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值