Use jQuery easyUI to create an RSS Feed reader

Source: Internet
Author: User

@ Author YHC

In this tutorial, we will create an rss reader using easyUI framework.

 


View DEMO


We will use the following plug-ins:


Layout: Create an application interface.
Datagrid: displays the rss feed list.
Tree: displays the feed channel.

Step 1: Create Layout
[Html]
<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>
& Lt; th field = "description" width = "200" & gt; Description & lt;/th & gt;
<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>

<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>
& Lt; th field = "description" width = "200" & gt; Description & lt;/th & gt;
<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> Step 2: The datagrid handles the event.
Here we want to handle some user-triggered events.


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

$ ('# 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 feed content and the 'onloadsuccess' event to select the first line.


Step 3: Process tree events
When the tree data has been loaded, We need to select the first leaf node, call the 'select' method to select the node, and use the 'onselect' event to obtain the selected node, so we can get the corresponding 'url' value.
In the end, we call the 'load' method of the datagrid to refresh the data in the feed list.
[Javascript]
$ ('# 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.tar get );
}
}
});

$ ('# 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.tar get );
}
}
}); Download EasyUI example:
Easyui-rssreader-demo.zip

 

Author: yhc13429826359
 

 

 

 

 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.