scout.blade.php 867 B

1234567891011121314151617181920212223
  1. $(function(){
  2. $('#%1$s').on('xhr.dt', function (e, settings, json, xhr) {
  3. if (json == null || !('disableOrdering' in json)) return;
  4. let table = {{ config('datatables-html.namespace', 'LaravelDataTables') }}[$(this).attr('id')];
  5. if (json.disableOrdering) {
  6. table.settings()[0].aoColumns.forEach(function(column) {
  7. column.bSortable = false;
  8. $(column.nTh).removeClass('sorting_asc sorting_desc sorting').addClass('sorting_disabled');
  9. });
  10. } else {
  11. let changed = false;
  12. table.settings()[0].aoColumns.forEach(function(column) {
  13. if (column.bSortable) return;
  14. column.bSortable = true;
  15. changed = true;
  16. });
  17. if (changed) {
  18. table.draw();
  19. }
  20. }
  21. });
  22. });