{"id":11627,"date":"2022-02-10T10:00:00","date_gmt":"2022-02-10T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=11627"},"modified":"2022-02-09T19:02:01","modified_gmt":"2022-02-09T10:02:01","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-2","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/11627","title":{"rendered":"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(2)"},"content":{"rendered":"\n<p>\u4eca\u56de\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\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<br>\u672c\u8a18\u4e8b\u306f\u300c<a href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/11534\" target=\"_blank\" rel=\"noreferrer noopener\">DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(1)<\/a>\u300d\u306e\u7d9a\u304d\u3067\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h4>DataTables\u306e\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9)<\/h4>\n\n\n\n<p>DataTables\u3092\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u3068\u9023\u643a\u3055\u305b\u308b\u305f\u3081\u306bJavascript\u3067\u306e\u30ed\u30fc\u30c9\u6642\u306e\u521d\u671f\u5316\u51e6\u7406\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$(function () {\n    $(\"#dttb\").DataTable({\n      \"responsive\": true, \n      \"lengthChange\": false, \n      \"autoWidth\": false,\n      \"processing\": true,\n      \"serverSide\": true,\n      \"ajax\": {\n            \"url\": \"{{url('\/')}}\/user_datatables\",\n            \"type\": \"POST\"\n        },\n        \"columns\": &#091;\n            { \"data\": \"item1\" },\n            { \"data\": \"item2\" },\n            { \"data\": \"item3\" },\n            { \"data\": \"item4\" },\n            { \"data\": \"item5\" },\n        ]\n    });\n  });\n<\/code><\/pre>\n\n\n\n<p><br>\u4e0a\u8a18\u306b\u8ffd\u52a0\u3057\u305f\u9805\u76ee\u306b\u3064\u3044\u3066\u4ee5\u4e0b\u306b\u8aac\u660e\u3057\u307e\u3059\u3002<br><br><strong>processing<\/strong>\uff1a\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u304b\u3089\u306e\u5fdc\u7b54\u3092\u5f85\u3063\u3066\u3044\u308b\u9593\u300c\u51e6\u7406\u4e2d\u3067\u3059\u300d\u3068\u8868\u793a\u3092\u304a\u3053\u306a\u3046\u305f\u3081\u306e\u8a2d\u5b9a\u3067\u3059\u3002<br><strong>serverSide<\/strong>\uff1a\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u3092\u304a\u3053\u306a\u3046\u8a2d\u5b9a\u3067\u3059\u3002<br><strong>ajax<\/strong>\uff1a\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u3092\u304a\u3053\u306a\u3046URL\u3068get\u307e\u305f\u306fpost\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br><strong>columns<\/strong>\uff1a\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u304b\u3089\u8fd4\u5374\u3055\u308c\u308bjson\u3068\u30c6\u30fc\u30d6\u30eb\u306b\u8868\u793a\u3059\u308b\u9805\u76ee\u540d\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4>DataTables\u306e\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(\u30d0\u30c3\u30af\u30a8\u30f3\u30c9)<\/h4>\n\n\n\n<p>\u6b21\u306f\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u5074\u306e\u8a2d\u5b9a\u3067\u3059\u3002<br>\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30d7\u30ed\u30b0\u30e9\u30e0\u306fLaravel\/PHP\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u306f \\routes\\web.php \u306b\u4e0a\u8a18\u306e\u51e6\u7406\u7528\u30eb\u30fc\u30c8\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br>DataTables\u306eajax\u3067\u306e\u8a2d\u5b9a(url\u304a\u3088\u3073type)\u306b\u3042\u308f\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Route::post('\/user_datatables', &#091;UserController::class, 'user_datatables']);\n<\/code><\/pre>\n\n\n\n<p><br>\u6b21\u306b\u4e0a\u8a18\u306e\u51e6\u7406\u7528\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u4f5c\u6210\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<br>\\app\\Http\\Controllers\\UserController.php<\/p>\n\n\n\n<p>\u307e\u305a\u306f\u52d5\u4f5c\u78ba\u8a8d\u7528\u3068\u3057\u3066\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a\u3067\u8fd4\u5374\u3059\u308bjson\u306e\u751f\u6210\u3092\u304a\u3053\u306a\u3044\u307e\u3059\u3002<br>json\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30b5\u30f3\u30d7\u30eb\u306f\u4ee5\u4e0b\u306eDataTables\u516c\u5f0f\u30b5\u30a4\u30c8\u306b\u8a18\u8f09\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/datatables.net\/examples\/data_sources\/server_side\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/datatables.net\/examples\/data_sources\/server_side<\/a><\/p>\n\n\n\n<p>\u4e0a\u8a18URL\u306e\u300cAjax\u300d\u30bf\u30d6\u3092\u958b\u304f\u3053\u3068\u3067\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u304b\u3089\u8fd4\u5374\u3059\u308bjson\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30b5\u30f3\u30d7\u30eb\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<br>\u3053\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306ejson\u3092\u8fd4\u5374\u3059\u308b\u3088\u3046\u306bLaravel\u3067\u7c21\u5358\u306a\u52d5\u4f5c\u78ba\u8a8d\u7528\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u8a18\u8f09\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function user_datatables(Request $request) {\n\n    $rec_data = &#091;];\n    $row_data = &#091;\n                    'item1' =&gt; \"a\",\n                    'item2' =&gt; \"b\",\n                    'item3' =&gt; \"c\",\n                    'item4' =&gt; \"d\",\n                    'item5' =&gt; \"e\",\n                ];\n\n    for ($i = 1; $i &lt;= 10; $i++) {\n        $rec_data&#091;] = $row_data;\n    }\n\n    $res_json = array(\n        'draw' =&gt; '1', \n        'recordsTotal' =&gt; '57', \n        'recordsFiltered' =&gt; '57', \n        'data' =&gt; $rec_data, \n    );\n\n    return response()-&gt;json($res_json);\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\u6b21\u56de\u306f\u4e0a\u8a18\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u52d5\u4f5c\u78ba\u8a8d\u306e\u7d50\u679c\u3068\u554f\u984c\u304c\u767a\u751f\u3057\u305f\u5834\u5408\u306e\u5bfe\u51e6\u65b9\u6cd5\u306b\u3064\u3044\u3066\u3054\u7d39\u4ecb\u3057\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\/11627\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/11627\" 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(2)\" 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\/11627\" data-text=\"DataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(2)\" 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\/11627\" 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\/11627\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\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\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u672c\u8a18\u4e8b\u306f\u300cDataTables\u3092\u4f7f\u7528\u3057\u305f\u30c6\u30fc\u30d6\u30eb\u751f\u6210\u3068\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u9023\u643a(1)\u300d\u306e\u7d9a\u304d\u3067\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\/11627"}],"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=11627"}],"version-history":[{"count":11,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11627\/revisions"}],"predecessor-version":[{"id":11641,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/11627\/revisions\/11641"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=11627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=11627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=11627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}