{"action":"closed","issue":{"url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1652","repository_url":"https://api.github.com/repos/yajra/laravel-datatables","labels_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1652/labels{/name}","comments_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1652/comments","events_url":"https://api.github.com/repos/yajra/laravel-datatables/issues/1652/events","html_url":"https://github.com/yajra/laravel-datatables/issues/1652","id":304438407,"number":1652,"title":"Slow performance","user":{"login":"BAKTETE","id":27772375,"avatar_url":"https://avatars0.githubusercontent.com/u/27772375?v=4","gravatar_id":"","url":"https://api.github.com/users/BAKTETE","html_url":"https://github.com/BAKTETE","followers_url":"https://api.github.com/users/BAKTETE/followers","following_url":"https://api.github.com/users/BAKTETE/following{/other_user}","gists_url":"https://api.github.com/users/BAKTETE/gists{/gist_id}","starred_url":"https://api.github.com/users/BAKTETE/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BAKTETE/subscriptions","organizations_url":"https://api.github.com/users/BAKTETE/orgs","repos_url":"https://api.github.com/users/BAKTETE/repos","events_url":"https://api.github.com/users/BAKTETE/events{/privacy}","received_events_url":"https://api.github.com/users/BAKTETE/received_events","type":"User","site_admin":false},"labels":[{"id":431228754,"url":"https://api.github.com/repos/yajra/laravel-datatables/labels/performance","name":"performance","color":"d4c5f9","default":false},{"id":67904193,"url":"https://api.github.com/repos/yajra/laravel-datatables/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-03-12T16:12:06Z","updated_at":"2018-03-13T22:34:09Z","closed_at":"2018-03-13T22:34:09Z","author_association":"NONE","body":"### Summary of problem or feature request\r\n\r\nSlow performance when loading 537 records\r\non page load : 4.34 seconds \r\non paginate : 3.98 seconds\r\n\r\n`\"pageLength\": 10`\r\nis there any possibility to limit rows per page like 10 from the query than when using pagination of datatable it will load the other 10 ... like the built in laravel pagination\r\n\r\nPS : even if pagination is disabled the loading time still 4.34 seconds\r\n\r\n\r\n\r\n### Code snippet of problem\r\n`Controller`\r\n```\r\npublic function membresData()\r\n    {\r\n\r\n        $membres = Membre::\r\n        join('equipes', 'equipes.id', '=', 'membres.equipe_id')\r\n        ->join('laboratoires', 'laboratoires.id', '=', 'equipes.laboratoire_id')\r\n        ->join('etablissements as e1', 'e1.id', '=', 'laboratoires.etablissement_id')\r\n        ->leftjoin('etablissements as e2', 'e2.id', '=', 'membres.etablissement_id')\r\n        ->leftjoin('profils', 'profils.id', '=', 'membres.profil_id')\r\n        ->leftjoin('typemembres', 'typemembres.id', '=', 'membres.typemembre_id')\r\n        ->select ('membres.id','equipes.axe_recherche','laboratoires.libelle','laboratoires.periode_accreditation_dd','laboratoires.periode_accreditation_df','e1.abbreviation as etablab','membres.nom', 'membres.prenom', 'membres.cv', 'membres.sujet', 'e2.abbreviation as etabmem', 'profils.typeprofil', 'membres.cin', 'membres.email','typemembres.typemembre')\r\n        ->orderBy('axe_recherche', 'asc')\r\n        ->get();\r\n\r\n        if(request()->ajax()){\r\n        return Datatables::of($membres)\r\n\r\n         ->addColumn('name', \r\n                '{{$nom}} {{$prenom}}'\r\n            )\r\n\r\n         ->addColumn('cv', function ($membre) {\r\n            if ($membre->cv != null){\r\n            $url=url(\"uploadedCvMembre/$membre->etablab/$membre->cv\");\r\n            return '<div data-provide=\"photoswipe\">\r\n                        <img class=\"avatar avatar-sm cursor-pointer\" src=\"'.$url.'\" alt=\"Curriculum vitae de : '.$membre->prenom.' '.$membre->nom.'\" data-provide=\"tooltip\" data-original-title=\"Curriculum vitae\" data-tooltip-color=\"primary\" aria-describedby=\"tooltip946475\">\r\n\r\n                    </div>   ';\r\n            }        \r\n         })\r\n\r\n         ->addColumn('laboratoire',\r\n                '« {{$etablab}} » {{ $libelle }} <small>{{ \\Carbon\\Carbon::parse($periode_accreditation_dd)->format(\"Y\") }} - {{ \\Carbon\\Carbon::parse($periode_accreditation_df)->format(\"Y\") }}</small>'\r\n            )\r\n         \r\n         ->addColumn('action', \r\n            '<nav class=\"nav gap-1 fs-16\">\r\n                        \r\n                        \r\n                            <a class=\"nav-link disabled hover-warning\" data-provide=\"tooltip\" data-tooltip-color=\"warning\" data-original-title=\"Modifier\" href=\"{{route(\"membre.edit\",$id)}}\"><i class=\"ti-pencil\"></i></a>\r\n                        \r\n\r\n                        \r\n                            <form method=\"POST\" action=\"{{ action(\"MembreController@destroy\", [\"id\" => $id]) }}\" class=\"delete_form\">\r\n                            @csrf\r\n                            @method(\"DELETE\")\r\n                            <a class=\"nav-link disabled hover-danger delete-btn\" data-provide=\"tooltip\" data-tooltip-color=\"danger\" data-original-title=\"Supprimer\" href=\"#\"><i class=\"ti-trash\"></i></a>\r\n                            </form>\r\n                         \r\n                    \r\n            </nav>'\r\n        )\r\n       \r\n         ->rawColumns(['cv','laboratoire','action'])\r\n         ->make(true);\r\n        }else{\r\n            abort('404');\r\n        }\r\n```\r\n`Js`\r\n```\r\napp.ready(function(){\r\n        $(\"#dtable\").dataTable().fnDestroy();\r\n        $('#dtable').DataTable({\r\n        \"columnDefs\": [\r\n            { \"visible\": false, \"targets\": [0,1] },\r\n            { \"orderable\": false, \"targets\": [-1] }\r\n        ],\r\n        \"order\": [[ 1, 'asc' ]],\r\n        processing: true,\r\n        serverSide: true,\r\n        ajax: '{!! route('membres') !!}',\r\n        deferRender: true,\r\n        columns: [\r\n            { data: 'laboratoire', name: 'laboratoire' },\r\n            { data: 'axe_recherche', name: 'axe_recherche' },\r\n            { data: 'name', name: 'name' },\r\n            { data: 'cv', name: 'cv', orderable: false, searchable: false },\r\n            { data: 'sujet', name: 'sujet' },\r\n            { data: 'etabmem', name: 'etabmem', orderable: false, searchable: false },\r\n            { data: 'typeprofil', name: 'typeprofil' },\r\n            { data: 'cin', name: 'cin' },\r\n            { data: 'email', name: 'email' },\r\n            { data: 'typemembre', name: 'typemembre' },\r\n            { data: 'action', name: 'action', orderable: false, searchable: false}\r\n\r\n        ],\r\n        \"drawCallback\": function ( settings ) {\r\n            $('[data-provide~=\"tooltip\"]').each(function(){var b=\"\";$(this).hasDataAttr(\"tooltip-color\")&&(b=\" tooltip-\"+$(this).data(\"tooltip-color\")),$(this).tooltip({container:\"body\",trigger:\"hover\",template:'<div class=\"tooltip'+b+'\" role=\"tooltip\"><div class=\"arrow\"></div><div class=\"tooltip-inner\"></div></div>'})});\r\n            var api = this.api();\r\n            var rows = api.rows( {page:'current'} ).nodes();\r\n            var last=null;\r\n \r\n            api.column(0, {page:'current'} ).data().each( function ( group, i ) {\r\n                if ( last !== group ) {\r\n                    $(rows).eq( i ).before(\r\n                        '<tr class=\"group bl-3 br-3 border-primary bg-light text-center\" ><td class=\"fw-500\" colspan=\"9\">'+group+'</td></tr>'\r\n                    );\r\n \r\n                    last = group;\r\n                }\r\n            } );\r\n            api.column(1, {page:'current'} ).data().each( function ( group, i ) {\r\n                if ( last !== group ) {\r\n                    $(rows).eq( i ).before(\r\n                        '<tr class=\"group bl-3 border-warning bg-light\" ><td class=\"fw-500\" colspan=\"9\">Equipe : '+group+'</td></tr>'\r\n                    );\r\n \r\n                    last = group;\r\n                }\r\n            } );\r\n     \r\n        }\r\n    });\r\n\r\n      \r\n  });\r\n```\r\n### System details\r\n\r\n<!--\r\nPlease include these details about your system!\r\nIf they are omitted, the ticket will be deprioritized\r\nover other users requests/tickets.\r\n-->\r\n\r\n- Operating System Ubuntu 17.10\r\n- PHP 7.2.2\r\n- Laravel 5.6\r\n- Laravel-Datatables 8.4\r\n"}}
{"actor":{"display_login":"BAKTETE"}}