{"id":11935,"date":"2022-04-07T10:00:00","date_gmt":"2022-04-07T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11935"},"modified":"2022-04-06T17:30:54","modified_gmt":"2022-04-06T08:30:54","slug":"datatables%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%83%86%e3%83%bc%e3%83%96%e3%83%ab%e7%94%9f%e6%88%90%e3%81%a8%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%82%b5%e3%82%a4%e3%83%89%e9%80%a3-7","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11935","title":{"rendered":"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(7)"},"content":{"rendered":"\n<p>\u672c\u8a18\u4e8b\u3067\u306fDataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u65b9\u6cd5\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u65b9\u6cd5\u3092\u30b7\u30a7\u30a2\u3057\u307e\u3059\u3002<br><a href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11890\" target=\"_blank\" rel=\"noreferrer noopener\">\u524d\u56de\u306e\u8a18\u4e8b<\/a>\u3067\u30da\u30fc\u30b8\u30f3\u30b0\u51e6\u7406\u304c\u3067\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u4eca\u56de\u306f\u30c7\u30fc\u30bf\u30c6\u30fc\u30d6\u30eb\u306e\u5404\u9805\u76ee\u306b\u30bd\u30fc\u30c8\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h4>\u30bd\u30fc\u30c8\u51e6\u7406\u306e\u8ffd\u52a0<\/h4>\n\n\n\n<p>DataTables\u3067\u306f\u5404\u9805\u76ee\u540d\u306e\u6a2a\u306b\u77e2\u5370\u30de\u30fc\u30af\u304c\u3064\u3044\u3066\u304a\u308a\u3001\u3053\u308c\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3053\u3068\u3067<br>\u5404\u9805\u76ee\u306e\u6607\u9806\u3001\u964d\u9806\u306b\u4e26\u3073\u66ff\u3048\u3092\u304a\u3053\u306a\u3046\u305f\u3081\u306e\u30c7\u30fc\u30bf\u3092<br>DataTables\u304c\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u306bpost\u3057\u3066\u304f\u308c\u307e\u3059\u3002<br>\u3053\u308c\u3089\u306e\u30c7\u30fc\u30bf\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\/\/\u4f55\u756a\u76ee\u306e\u9805\u76ee\u3092\u30bd\u30fc\u30c8\u3059\u308b\u304b<br>$order_column_num = $request-&gt;order[0][&#8216;column&#8217;];<\/p>\n\n\n\n<p>\/\/\u6607\u9806(asc)\u307e\u305f\u306f\u964d\u9806(desc)\u306e\u3069\u3061\u3089\u3067\u4e26\u3073\u66ff\u3048\u3092\u304a\u3053\u306a\u3046\u304b<br>$order_dir = $request-&gt;order[0][&#8216;dir&#8217;];<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30c7\u30fc\u30bf\u3092Laravel\u3067\u53d7\u3051\u53d6\u308a\u3001orderBy\u306b\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u30bd\u30fc\u30c8\u51e6\u7406\u3092\u304a\u3053\u306a\u3046\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<br>\u5b9f\u4f8b\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function user_datatables(Request $request) {\n\n    $rec_data = &#091;];\n    $query = Member::query();\n    $total_cnt = $query-&gt;count();\n    $length = $request-&gt;length;\n    $start = $request-&gt;start;\n\n    \/\/\u30bd\u30fc\u30c8\u51e6\u7406 start\n    $order_column = &#091;\n                        'id', \n                        'sei', \n                        'sei_kana', \n                        'mail', \n                        'created_at', \n                    ];\n\n    \/\/\u4f55\u756a\u76ee\u306e\u9805\u76ee\u3092\u30bd\u30fc\u30c8\u3059\u308b\u304b\n    $order_column_num = $request-&gt;order&#091;0]&#091;'column'];\n\n    \/\/\u6607\u9806(asc)\u307e\u305f\u306f\u964d\u9806(desc)\u306e\u3069\u3061\u3089\u3067\u4e26\u3073\u66ff\u3048\u3092\u304a\u3053\u306a\u3046\u304b\n    $order_dir = $request-&gt;order&#091;0]&#091;'dir'];\n\n    $query-&gt;orderBy($order_column&#091;$order_column_num], $order_dir);\n    \/\/\u30bd\u30fc\u30c8\u51e6\u7406 end\n\n    $query-&gt;offset($start);\n    $query-&gt;limit($length);\n    $member_list = $query-&gt;get();\n    foreach($member_list as $member){\n        $row_data = &#091;\n            'item1' =&gt; $member-&gt;id,\n            'item2' =&gt; $member-&gt;sei.$member-&gt;mei,\n            'item3' =&gt; $member-&gt;sei_kana.$member-&gt;mei_kana,\n            'item4' =&gt; $member-&gt;mail,\n            'item5' =&gt; $member-&gt;created_at-&gt;format('Y-m-d H:i'),\n        ];\n        $rec_data&#091;] = $row_data;\n    }\n\n    $draw = $request-&gt;draw;\n    $res_json = array(\n        'draw' =&gt; $draw, \n        'recordsTotal' =&gt; $total_cnt, \n        'recordsFiltered' =&gt; $total_cnt, \n        'data' =&gt; $rec_data, \n    );\n\n    return response()-&gt;json($res_json);\n}\n<\/code><\/pre>\n\n\n\n<p><br>\u4ee5\u4e0a\u3067\u30bd\u30fc\u30c8\u51e6\u7406\u306e\u8a2d\u5b9a\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\u306e\u3067\u52d5\u4f5c\u78ba\u8a8d\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u25a0ID\u306e\u6607\u9806(asc)\u3067\u30bd\u30fc\u30c8<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"800\" height=\"610\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/id_a.png\" alt=\"\" class=\"wp-image-11940\" \/><\/figure>\n\n\n\n<p>\u25a0ID\u306e\u964d\u9806(desc)\u3067\u30bd\u30fc\u30c8<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"803\" height=\"616\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/id_d.png\" alt=\"\" class=\"wp-image-11944\" \/><\/figure>\n\n\n\n<p>\u25a0\u30d5\u30ea\u30ac\u30ca\u306e\u6607\u9806(asc)\u3067\u30bd\u30fc\u30c8<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"796\" height=\"623\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/kana_a.png\" alt=\"\" class=\"wp-image-11945\" \/><\/figure>\n\n\n\n<p>\u25a0\u30d5\u30ea\u30ac\u30ca\u306e\u964d\u9806(desc)\u3067\u30bd\u30fc\u30c8<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"809\" height=\"617\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/kana_d.png\" alt=\"\" class=\"wp-image-11946\" \/><\/figure>\n\n\n\n<p>\u25a0\u30e1\u30fc\u30eb\u306e\u6607\u9806(asc)\u3067\u30bd\u30fc\u30c8<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"801\" height=\"607\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/mail_a.png\" alt=\"\" class=\"wp-image-11947\" \/><\/figure>\n\n\n\n<p>\u25a0\u30e1\u30fc\u30eb\u306e\u964d\u9806(desc)\u3067\u30bd\u30fc\u30c8<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"805\" height=\"607\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/mail_d.png\" alt=\"\" class=\"wp-image-11949\" \/><\/figure>\n\n\n\n<p><br>\u4ee5\u4e0a\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u6b21\u56de\u306f\u691c\u7d22\u6a5f\u80fd\u306e\u8ffd\u52a0\u3092\u304a\u3053\u306a\u3044\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6728\u66dc\u65e5\u62c5\u5f53\uff1anishida<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11935\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11935\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(7)\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11935\" data-text=\"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(7)\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11935\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11935\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u8a18\u4e8b\u3067\u306fDataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u65b9\u6cd5\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u65b9\u6cd5\u3092\u30b7\u30a7\u30a2\u3057\u307e\u3059\u3002\u524d\u56de\u306e\u8a18\u4e8b\u3067\u30da\u30fc\u30b8\u30f3\u30b0\u51e6\u7406\u304c\u3067\u304d\u307e\u3057\u305f\u306e\u3067\u3001\u4eca\u56de\u306f\u30c7\u30fc\u30bf\u30c6\u30fc\u30d6\u30eb\u306e\u5404\u9805\u76ee\u306b\u30bd\u30fc\u30c8\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11935"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=11935"}],"version-history":[{"count":8,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11935\/revisions"}],"predecessor-version":[{"id":11952,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11935\/revisions\/11952"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}