{"id":28,"date":"2008-02-13T23:12:24","date_gmt":"2008-02-13T15:12:24","guid":{"rendered":"http:\/\/amjet.dyndns.biz\/blog\/IT\/?p=28"},"modified":"2013-03-01T19:50:47","modified_gmt":"2013-03-01T11:50:47","slug":"yahoo-ui-datatable-%e4%bd%bf%e7%94%a8%e7%af%84%e4%be%8b","status":"publish","type":"post","link":"https:\/\/blog.amjet.biz\/IT\/?p=28","title":{"rendered":"Yahoo UI DataTable \u4f7f\u7528\u7bc4\u4f8b"},"content":{"rendered":"<p>\u5728\u8a2d\u8a08\u7db2\u8def\u61c9\u7528\u7a0b\u5f0f\u6642\uff0c\u5e38\u5fc5\u9808\u5448\u73fe\u8868\u683c\u8cc7\u6599\uff0c\u8868\u683c\u5448\u73fe\u51fa\u4f86\u5f8c\uff0c\u7528\u6236\u4e5f\u5fc5\u5b9a\u76f4\u89ba\u7684\u767c\u554f\uff0c\u8cc7\u6599\u9019\u9ebc\u591a\u53ef\u4e0d\u53ef\u4ee5\u5206\u9801\u986f\u793a\uff0c\u53ef\u4e0d\u53ef\u4ee5\u7a0d\u5fae\u6392\u5e8f\u4e00\u4e0b\u3002\u81ea\u5df1\u4f86 coding \u7576\u7136\u53ea\u662f\u591a\u82b1\u9ede\u6642\u9593\u800c\u5df2\uff0c\u73fe\u5728 <a href=\"http:\/\/developer.yahoo.com\/yui\/index.html\">Yahoo UI<\/a> \u4e0d\u53ea\u53ef\u4ee5\u63d0\u4f9b\u9019\u4e9b\u529f\u80fd\uff0c\u9084\u6709\u66f4\u591a\u7684\u63a7\u5236\u9078\u9805\u53ef\u4ee5\u8abf\u6574\uff0c\u66f4\u597d\u7684\u662f\u4e0d\u7528\u70ba browser \u76f8\u5bb9\u6027\u50b7\u8166\u7b4b\u3002Yahoo UI \u7db2\u7ad9\u5df2\u7d93\u6709\u76f8\u7576\u5b8c\u6574\u7684\u7bc4\u4f8b\u4e86\uff0c\u53ea\u662f\u770b\u4e0d\u592a\u7fd2\u6163\u81ea\u5df1\u4f86\u5beb\u4e00\u500b\u3002<\/p>\n<p>\u9996\u5148\u8981\u5148 include \u4ee5\u4e0b\u7684 css\u3001 js \u6a94<\/p>\n<p>&lt;!&#8211; datatable includes below &#8211;&gt;<br \/>\n&lt;link rel=&#8221;stylesheet&#8221; type=&#8221;text\/css&#8221; href=&#8221;\/js\/yui\/build\/datatable\/assets\/skins\/sam\/datatable.css&#8221;&gt;<br \/>\n&lt;script src=&#8221;\/js\/yui\/build\/yahoo-dom-event\/yahoo-dom-event.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script src=&#8221;\/js\/yui\/build\/element\/element-beta-min.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script src=&#8221;\/js\/yui\/build\/datasource\/datasource-beta-min.js&#8221;&gt;&lt;\/script&gt;<br \/>\n&lt;script src=&#8221;\/js\/yui\/build\/datatable\/datatable-beta-min.js&#8221;&gt;&lt;\/script&gt;<\/p>\n<p>\u63a5\u4e0b\u4f86\u5728 body \u5167\u7559\u4e00\u500b container \u7d66 Yahoo UI \u653e\u7522\u751f\u7684 table<\/p>\n<p>&lt;body class=&#8221;yui-skin-sam&#8221;&gt;<\/p>\n<p>&lt;div id=&#8221;DataTableYUI&#8221;&gt;&lt;\/div&gt;<\/p>\n<p>\u518d\u4f86\u6e96\u50991\u652f\u7a0b\u5f0f\u9935\u8cc7\u6599\u7d66 DataTable \u5143\u4ef6\uff0c\u4f8b\u5982\u4ee5\u4e0b datafeed.php<\/p>\n<p>&lt;?php<\/p>\n<p>$sql=&#8221;select name,age from user&#8221;;<br \/>\n$result=mysql_query($sql);<\/p>\n<p>$data=array();<br \/>\nif ( $result ) {<br \/>\nwhile ( $row=mysql_fetch_assoc($result) ) {<br \/>\narray_push($data,$row);<br \/>\n}<br \/>\n$status=0;<br \/>\n} else {<br \/>\n$status=1;<br \/>\n}<\/p>\n<p>$response[&#8216;status&#8217;]=$status;<br \/>\n$response[&#8216;data&#8217;]=$data;<\/p>\n<p>echo json_encode($response);<\/p>\n<p>?&gt;<\/p>\n<p>\u5229\u7528\u4ee5\u4e0b javascript \u5373\u53ef\u5c07 data table \u5448\u73fe\u5728\u4e4b\u524d\u5b9a\u7fa9\u7684 div \u5167<\/p>\n<p>function showDataTable() {<br \/>\nvar ds=new YAHOO.util.DataSource(&#8220;datafeed.php&#8221;);<br \/>\nds.responseType=YAHOO.util.DataSource.TYPE_JSON;<br \/>\nds.responseSchema={<br \/>\nresultsList: &#8220;data&#8221;,<br \/>\nfields: [&#8220;name&#8221;,&#8221;age&#8221;]<br \/>\n};<br \/>\nvar cols=[<br \/>\n{ key: &#8220;name&#8221;, label: &#8220;User name&#8221; },<br \/>\n{ key: &#8220;age&#8221;, label: &#8220;User age&#8221;, sortable: &#8220;true&#8221; }<br \/>\n];<br \/>\nvar dt=new YAHOO.widget.DataTable(&#8220;DataTableYUI&#8221;, cols, ds, {} );<br \/>\n}<\/p>\n<p>Yahoo UI \u7db2\u7ad9\u9084\u6709\u66f4\u591a\u7684\u7bc4\u4f8b\u53ca API \u8aaa\u660e\u53ef\u4ee5\u53c3\u8003\u3002<\/p>\n<p><strong>[ratings]<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u8a2d\u8a08\u7db2\u8def\u61c9\u7528\u7a0b\u5f0f\u6642\uff0c\u5e38\u5fc5\u9808\u5448\u73fe\u8868\u683c\u8cc7\u6599\uff0c\u8868\u683c\u5448\u73fe\u51fa\u4f86\u5f8c\uff0c\u7528\u6236\u4e5f\u5fc5\u5b9a\u76f4\u89ba\u7684\u767c\u554f\uff0c\u8cc7\u6599\u9019\u9ebc\u591a\u53ef\u4e0d\u53ef\u4ee5\u5206\u9801\u986f\u793a\uff0c\u53ef\u4e0d\u53ef\u4ee5\u7a0d\u5fae\u6392\u5e8f\u4e00\u4e0b\u3002\u81ea\u5df1\u4f86 coding \u7576\u7136\u53ea\u662f\u591a\u82b1\u9ede\u6642\u9593\u800c\u5df2\uff0c\u73fe\u5728 Yahoo UI \u4e0d\u53ea\u53ef\u4ee5\u63d0\u4f9b\u9019\u4e9b\u529f\u80fd\uff0c\u9084\u6709\u66f4\u591a\u7684\u63a7\u5236\u9078\u9805\u53ef\u4ee5\u8abf\u6574\uff0c\u66f4\u597d\u7684\u662f\u4e0d\u7528\u70ba browser \u76f8\u5bb9\u6027\u50b7\u8166\u7b4b\u3002Yahoo UI \u7db2\u7ad9\u5df2\u7d93\u6709\u76f8\u7576\u5b8c\u6574\u7684\u7bc4\u4f8b\u4e86\uff0c\u53ea\u662f\u770b\u4e0d\u592a\u7fd2\u6163\u81ea\u5df1\u4f86\u5beb\u4e00\u500b\u3002 \u9996\u5148\u8981\u5148 include \u4ee5\u4e0b\u7684 css\u3001 js \u6a94 &lt;!&#8211; datatable includes below &#8211;&gt; &lt;link rel=&#8221;stylesheet&#8221; type=&#8221;text\/css&#8221; href=&#8221;\/js\/yui\/build\/datatable\/assets\/skins\/sam\/datatable.css&#8221;&gt; &lt;script src=&#8221;\/js\/yui\/build\/yahoo-dom-event\/yahoo-dom-event.js&#8221;&gt;&lt;\/script&gt; &lt;script src=&#8221;\/js\/yui\/build\/element\/element-beta-min.js&#8221;&gt;&lt;\/script&gt; &lt;script src=&#8221;\/js\/yui\/build\/datasource\/datasource-beta-min.js&#8221;&gt;&lt;\/script&gt; &lt;script src=&#8221;\/js\/yui\/build\/datatable\/datatable-beta-min.js&#8221;&gt;&lt;\/script&gt; \u63a5\u4e0b\u4f86\u5728 body \u5167\u7559\u4e00\u500b container \u7d66 Yahoo UI \u653e\u7522\u751f\u7684 table &lt;body class=&#8221;yui-skin-sam&#8221;&gt; &lt;div id=&#8221;DataTableYUI&#8221;&gt;&lt;\/div&gt; \u518d\u4f86\u6e96\u50991\u652f\u7a0b\u5f0f\u9935\u8cc7\u6599\u7d66 DataTable \u5143\u4ef6\uff0c\u4f8b\u5982\u4ee5\u4e0b datafeed.php &lt;?php $sql=&#8221;select name,age from user&#8221;; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[89,88],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-ajax","tag-datatable","tag-yahoo-ui"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=28"}],"version-history":[{"count":4,"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":736,"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions\/736"}],"wp:attachment":[{"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amjet.biz\/IT\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}