Easy Tutorial
❮ Jeasyui Tree Treegrid2 Plugins Form Combotree ❯

jQuery EasyUI Application - Creating an RSS Feed Reader

In this tutorial, we will create an RSS reader using the jQuery EasyUI framework.

We will use the following plugins:

Step 1: Create the Layout

<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>

Step 2: DataGrid Event Handling

Here, we will handle some events triggered by the user.

$('#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 row.

Step 3: Tree Event Handling

When the Tree data is loaded, we need to select the first leaf node and call the 'select' method to select that node. Using the 'onSelect' event to get the selected node, we can then obtain the corresponding 'url' value. Finally, we call the 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 jQuery EasyUI Example

jeasyui-app-rssreader.zip

❮ Jeasyui Tree Treegrid2 Plugins Form Combotree ❯