无为清净楼资源网 Design By www.qnjia.com
说句老实话,我目前还对Ext技术不是很熟,所以写的代码自己也觉得怪怪的,有什么不对的地方,还望赐教。
使用的Ext版本是ext-2.2,下载地址为:http://www.extjs.com/products/extjs/download.php
下载Ext JS 2.2 SDK,解压后拷贝resources文件夹至工作目录。
在resources文件夹下新建jscript文件夹,并拷贝ext根目录下ext-all.js文件及adapter\ext\ext-base.js文件至jscript文件夹下,并新建stock.js文件,代码如下:
复制代码 代码如下:
function ajaxRequest(){
Ext.Ajax.request({
url: 'http://hq.sinajs.cn/list=sh000001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601398,sh601857,sh600028,',
success: function(response){
var stocks = response.responseText.split(';');
var length = stocks.length - 2;
var dataset = new Array(length);
for(var i=0; i<length; i++){
var content = stocks[i];
var temp1 = content.split('=')[0];
var temp2 = content.split('=')[1];
var code = temp1.substr(temp1.length - 6, 6);
var temp3 = temp2.replace('"', '');
var name = temp3.split(',')[0];
var tday_f = temp3.split(',')[1];
var yest_f = temp3.split(',')[2];
var curr_f = temp3.split(',')[3];
var temp_f = curr_f - yest_f;
var data_i = new Array(9);
data_i[0] = code;
data_i[1] = name;
data_i[2] = curr_f;
data_i[3] = tday_f;
data_i[4] = yest_f;
data_i[5] = temp_f.toFixed(2);
data_i[6] = ((temp_f / yest_f) * 100).toFixed(2);
data_i[7] = temp3.split(',')[4];
data_i[8] = temp3.split(',')[5];
dataset[i] = data_i;
}
var store = new Ext.data.SimpleStore({
fields: [
{name: 'a1'},
{name: 'a2'},
{name: 'a3'},
{name: 'a4'},
{name: 'a5'},
{name: 'a6'},
{name: 'a7'},
{name: 'a8'},
{name: 'a9'}
]
});
//store.loadData(dataset);
var grid = new Ext.grid.GridPanel({
//renderTo: document.body,
store: store,
columns: [
{header: "股票代号", width: 100, sortable: true, dataIndex: 'a1', id:'a1'},
{header: "股票名称", width: 100, sortable: true, dataIndex: 'a2'},
{header: "当前价格", width: 100, sortable: true, dataIndex: 'a3'},
{header: "今日开盘", width: 100, sortable: true, dataIndex: 'a4'},
{header: "昨日收盘", width: 100, sortable: true, dataIndex: 'a5'},
{header: "当前差价", width: 100, sortable: true, dataIndex: 'a6', renderer: change},
{header: "涨跌幅度", width: 100, sortable: true, dataIndex: 'a7', renderer: change},
{header: "最高价格", width: 100, sortable: true, dataIndex: 'a8'},
{header: "最低价格", width: 100, sortable: true, dataIndex: 'a9'}
],
stripeRows: true,
autoExpandColumn: 'a1',
height:240,
width:740,
title:'股票信息一览'
});
if(document.getElementById("stockgrid").innerHTML == ""){
grid.render('stockgrid');
grid.getSelectionModel().selectFirstRow();
}
grid.store.loadData(dataset);
}
});
}
function change(val){
if(val < 0){
return '<span style="color:green;">' + val + '</span>';
}else if(val > 0){
return '<span style="color:red;">' + val + '</span>';
}
return val;
}
Ext.onReady(function(){
//修正页面启动时提示下载http://extjs.com/s.gif的问题
Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
ajaxRequest();
window.setInterval("ajaxRequest()",3000);
});
在工作目录下新建stock.html文件,代码如下:
复制代码 代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>股票信息</title>
<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<script type="text/javascript" src="/UploadFiles/2021-04-02/ext-base.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/ext-all.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/stock.js"></head>
<body>
<div id="stockgrid"></div>
</body>
</html>
从这里可以看到,使用Ext技术,动态页面从页面表现层到数据取得全部都交由Ext来处理。
使用的Ext版本是ext-2.2,下载地址为:http://www.extjs.com/products/extjs/download.php
下载Ext JS 2.2 SDK,解压后拷贝resources文件夹至工作目录。
在resources文件夹下新建jscript文件夹,并拷贝ext根目录下ext-all.js文件及adapter\ext\ext-base.js文件至jscript文件夹下,并新建stock.js文件,代码如下:
复制代码 代码如下:
function ajaxRequest(){
Ext.Ajax.request({
url: 'http://hq.sinajs.cn/list=sh000001,sh601939,sh600016,sh600528,sh600667,sh601390,sh601398,sh601857,sh600028,',
success: function(response){
var stocks = response.responseText.split(';');
var length = stocks.length - 2;
var dataset = new Array(length);
for(var i=0; i<length; i++){
var content = stocks[i];
var temp1 = content.split('=')[0];
var temp2 = content.split('=')[1];
var code = temp1.substr(temp1.length - 6, 6);
var temp3 = temp2.replace('"', '');
var name = temp3.split(',')[0];
var tday_f = temp3.split(',')[1];
var yest_f = temp3.split(',')[2];
var curr_f = temp3.split(',')[3];
var temp_f = curr_f - yest_f;
var data_i = new Array(9);
data_i[0] = code;
data_i[1] = name;
data_i[2] = curr_f;
data_i[3] = tday_f;
data_i[4] = yest_f;
data_i[5] = temp_f.toFixed(2);
data_i[6] = ((temp_f / yest_f) * 100).toFixed(2);
data_i[7] = temp3.split(',')[4];
data_i[8] = temp3.split(',')[5];
dataset[i] = data_i;
}
var store = new Ext.data.SimpleStore({
fields: [
{name: 'a1'},
{name: 'a2'},
{name: 'a3'},
{name: 'a4'},
{name: 'a5'},
{name: 'a6'},
{name: 'a7'},
{name: 'a8'},
{name: 'a9'}
]
});
//store.loadData(dataset);
var grid = new Ext.grid.GridPanel({
//renderTo: document.body,
store: store,
columns: [
{header: "股票代号", width: 100, sortable: true, dataIndex: 'a1', id:'a1'},
{header: "股票名称", width: 100, sortable: true, dataIndex: 'a2'},
{header: "当前价格", width: 100, sortable: true, dataIndex: 'a3'},
{header: "今日开盘", width: 100, sortable: true, dataIndex: 'a4'},
{header: "昨日收盘", width: 100, sortable: true, dataIndex: 'a5'},
{header: "当前差价", width: 100, sortable: true, dataIndex: 'a6', renderer: change},
{header: "涨跌幅度", width: 100, sortable: true, dataIndex: 'a7', renderer: change},
{header: "最高价格", width: 100, sortable: true, dataIndex: 'a8'},
{header: "最低价格", width: 100, sortable: true, dataIndex: 'a9'}
],
stripeRows: true,
autoExpandColumn: 'a1',
height:240,
width:740,
title:'股票信息一览'
});
if(document.getElementById("stockgrid").innerHTML == ""){
grid.render('stockgrid');
grid.getSelectionModel().selectFirstRow();
}
grid.store.loadData(dataset);
}
});
}
function change(val){
if(val < 0){
return '<span style="color:green;">' + val + '</span>';
}else if(val > 0){
return '<span style="color:red;">' + val + '</span>';
}
return val;
}
Ext.onReady(function(){
//修正页面启动时提示下载http://extjs.com/s.gif的问题
Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
ajaxRequest();
window.setInterval("ajaxRequest()",3000);
});
在工作目录下新建stock.html文件,代码如下:
复制代码 代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>股票信息</title>
<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<script type="text/javascript" src="/UploadFiles/2021-04-02/ext-base.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/ext-all.js"><script type="text/javascript" src="/UploadFiles/2021-04-02/stock.js"></head>
<body>
<div id="stockgrid"></div>
</body>
</html>
从这里可以看到,使用Ext技术,动态页面从页面表现层到数据取得全部都交由Ext来处理。
标签:
EXT,无刷新,动态调用
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年11月06日
2024年11月06日
- 雨林唱片《赏》新曲+精选集SACD版[ISO][2.3G]
- 罗大佑与OK男女合唱团.1995-再会吧!素兰【音乐工厂】【WAV+CUE】
- 草蜢.1993-宝贝对不起(国)【宝丽金】【WAV+CUE】
- 杨培安.2009-抒·情(EP)【擎天娱乐】【WAV+CUE】
- 周慧敏《EndlessDream》[WAV+CUE]
- 彭芳《纯色角3》2007[WAV+CUE]
- 江志丰2008-今生为你[豪记][WAV+CUE]
- 罗大佑1994《恋曲2000》音乐工厂[WAV+CUE][1G]
- 群星《一首歌一个故事》赵英俊某些作品重唱企划[FLAC分轨][1G]
- 群星《网易云英文歌曲播放量TOP100》[MP3][1G]
- 方大同.2024-梦想家TheDreamer【赋音乐】【FLAC分轨】
- 李慧珍.2007-爱死了【华谊兄弟】【WAV+CUE】
- 王大文.2019-国际太空站【环球】【FLAC分轨】
- 群星《2022超好听的十倍音质网络歌曲(163)》U盘音乐[WAV分轨][1.1G]
- 童丽《啼笑姻缘》头版限量编号24K金碟[低速原抓WAV+CUE][1.1G]