[JQuery] DataTables

DataTables 是一個在資金所限但又要用DataGrid 情況下的一個替代品. 透過JQuery, 可以將資料從JSON 中顯示出來.

看了教學, 其實使用不難. 最簡單從Web Request 存取資料方法如下:

<table id="example" class="display" style="width:100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Extn.</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
    </table>
<SCRIPT type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable( {
        "ajax": "http://www.aaa.com",
        "data": function ( d ) {
"active": true
}
        "columns": [
            { "data": "name" },
            { "data": "position" },
            { "data": "office" },
            { "data": "extn" },
            { "data": "start_date" },
            { "data": "salary" }
        ]
    } );
} );
</script>

初步用上來算不錯. 但若與Angular 等比較, 沒有Binding 是它最大的失敗之處. 希望有機會它可以將它整合到Angular / React 這類Framework 中吧.

參考資料

About C.H. Ling 260 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.