论坛首页 Web前端技术论坛

ExtJs 2.0 构建的rss新闻 案例

浏览 4363 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-10-17  
只有实践才是检验理论是否正确的最好方法 —— 陈治文



这个EXT 2.0 的例子 讲的是怎么样用aspserver和ext2.0构建rss新闻!

服务器部分:

   var _http = new XMLHttp() ;
 
  var _return = _http.get("http://rss.sina.com.cn/news/china/focus15.xml") ;
 
 Write.writeXML(_return) ;




网页部分:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>新闻列表示例</title>
<link type="text/css" rel="stylesheet" href="js/ext/resources/css/ext-all.css"/>
<script type="text/javascript" src="js/ext/adapter/ext/ext-base.js">
</script>
<script type="text/javascript" src="js/ext/ext-all.js">
</script>
<script type="text/javascript" src="js/ext/source/locale/ext-lang-zh_CN.js">
</script>
<script type="text/javascript" src="js/demo.js">
</script>
</head>
<body>
<div id="example_grid"></div>
</body>
</html>


JS部分:

Ext.BLANK_IMAGE_URL = 'js/ext/resources/images/default/s.gif';
Ext.onReady(function(){
 function formatDate(_value){
  var _date = new Date(_value) ;
        return _date.format("Y-m-d H:i:s");
    };
    var _grid = new Ext.grid.GridPanel({
        ds: new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
     url: "../app/demo.asp"
    }),
    reader: new Ext.data.XmlReader({
        record: "item"
       }, [
        {name: "title", mapping: "title"},
        {name: "datetime", mapping: "pubDate"},
        {name:"link" , mapping:"link"}
       ])
   }),
        cm: new Ext.grid.ColumnModel([
   {header: "新闻名称", width: 300, dataIndex: "title"},
   {header: "新闻发布时间", width: 130, dataIndex: "datetime" , renderer: function(_value){
    var _date = new Date(_value) ;
          return _date.format("Y-m-d H:i:s");
   }},
   {header: "新闻链接", width: 350, dataIndex: "link" , renderer:function(_value){
    return "<a target = \"_blank\" href = \"" + _value + "\">" + _value + "</a>" ;
   }}
  ]),
       renderTo:"example_grid",
        width:800,
        height:300,
  loadMask: true
    });
    _grid.getStore().load();
}) ;


源代码下载:见www.dojochina.com  请批评指正!
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics