原創(chuàng)|使用教程|編輯:龔雪|2015-09-22 08:45:26.000|閱讀 465 次
概述:在本教程中,我們將為大家展示如何使用jQuery EasyUI框架創(chuàng)建一個RSS閱讀器!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Kendo UI for jQuery——創(chuàng)建現(xiàn)代Web應(yīng)用程序的最完整UI庫!查看詳情>>>
在本文中,我們將使用jQuery EasyUI框架創(chuàng)建一個RSS閱讀器。
我們將使用以下插件:
<body class="easyui-layout"> <div region="north" border="false" class="rtitle"> jQuery EasyUI RSS Reader Demo </div> <div region="west" title="Channels Tree" split="true" border="false" style="width:200px;background:#EAFDFF;"> <ul id="t-channels" url="data/channels.json"></ul> </div> <div region="center" border="false"> <div class="easyui-layout" fit="true"> <div region="north" split="true" border="false" style="height:200px"> <table id="dg" url="get_feed.php" border="false" rownumbers="true" fit="true" fitColumns="true" singleSelect="true"> <thead> <tr> <th field="title" width="100">Title</th> <th field="description" width="200">Description</th> <th field="pubdate" width="80">Publish Date</th> </tr> </thead> </table> </div> <div region="center" border="false" style="overflow:hidden"> <iframe id="cc" scrolling="auto" frameborder="0" style="width:100%;height:100%"></iframe> </div> </div> </div> </body>
在這里,我們需要處理一些由用戶觸發(fā)的事件。
$('#dg').datagrid({ onSelect: function(index,row){ $('#cc').attr('src', row.link); }, onLoadSuccess:function(){ var rows = $(this).datagrid('getRows'); if (rows.length){ $(this).datagrid('selectRow',0); } } });
在這個示例中調(diào)用'onSelect'事件來顯示Feed的內(nèi)容,同時調(diào)用'onLoadSuccess'事件來選擇第一行。
當tree數(shù)據(jù)被加載時,我們需要選擇第一個子節(jié)點,調(diào)用'select'方法來選擇該節(jié)點。使用'onSelect'事件來獲得被選擇的節(jié)點,這樣就能得到對應(yīng)的'url'值。最后,我們調(diào)用數(shù)據(jù)網(wǎng)格的'load'方法來刷新Feed列表。
$('#t-channels').tree({ onSelect: function(node){ var url = node.attributes.url; $('#dg').datagrid('load',{ url: url }); }, onLoadSuccess:function(node,data){ if (data.length){ var id = data[0].children[0].children[0].id; var n = $(this).tree('find', id); $(this).tree('select', n.target); } } });
下載該EasyUI示例:
購買最新正版授權(quán)!<>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)