轻松学习jQuery插件EasyUI EasyUI创建RSS Feed阅读器

轻松学习jQuery插件EasyUI EasyUI创建RSS Feed阅读器

我们将使用以下插件:
layout:创建应用的用户界面。
datagrid:显示 RSS Feed 列表。
tree:显示 feed 频道。
步骤 1:创建布局(Layout)

<body> <div region="north"> jQuery EasyUI RSS Reader Demo </div> <div region="west" title="Channels Tree" split="true"> <ul url="data/channels.json"></ul> </div> <div region="center"> <div fit="true"> <div region="north" split="true"> <table url="get_feed.php" rownumbers="true" fit="true" fitColumns="true" singleSelect="true"> <thead> <tr> <th field="title">Title</th> <th field="description">Description</th> <th field="pubdate">Publish Date</th> </tr> </thead> </table> </div> <div region="center"> <iframe scrolling="auto" frameborder="0"></iframe> </div> </div> </div> </body>

步骤 2:数据网格(DataGrid)处理事件

在这里我们要处理一些由用户触发的事件。

$('#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); } } });

本实例使用 'onSelect' 事件来显示 feed 的内容,使用 'onLoadSuccess' 事件来选择第一行。
步骤 3:树形菜单(Tree)处理事件

当树形菜单(Tree)数据已经加载,我们需要选择第一个叶子节点,调用 'select' 方法来选择该节点。 使用 'onSelect' 事件来得到已选择的节点,这样我们就能得到对应的 'url' 值。 最后我们调用数据网格(DataGrid) 的 '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); } } });

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgzzss.html