Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

jQuery EasyUI App - Create an RSS feed reader


May 08, 2021 jQuery EasyUI


Table of contents


jQuery EasyUI app - Create an RSS feed reader

In this section, we'll show you how to use the jQuery EasyUI framework to create an RSS feed reader.

jQuery EasyUI App - Create an RSS feed reader

Here's what plug-ins we'll use and how they'll work:

  • layout: Create the user interface for your app.
  • Datagrid: Displays a list of RSS feeds.
  • Tree: Show feed channels.

Step 1: Create a layout

<body class="easyui-layout"&gt;
	<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>
&lt;/body&gt;

Step 2: DataGrid handles events

In this step, we deal with some user-triggered events:

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

This example uses the 'onSelect' event to display the contents of the feed, and the 'onLoadSuccess' event is used to select the first line.

Step 3: Tree menu handles events

When the Tree data is loaded, we need to select the first leaf node and call the 'select' method to select that node. U se the 'onSelect' event to get the selected node so that we can get the corresponding 'url' value. Finally, we call dataGrid's 'load' method to refresh the feed list data.

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

Download the jQuery EasyUI instance

jeasyui-app-rssreader.zip