Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3.2k stars 900 forks source link

Disable AJAX in crud controller #1121

Closed jsiebach closed 7 years ago

jsiebach commented 7 years ago

While the AJAX functionality is great for most use cases, I have a number of crud controllers that are not functional with the new forced AJAX. These have accessors that create the text for each column which are not in the database, and therefore not searchable, even using custom search logic. I was a bit quick to upgrade perhaps and hadn't realized 3.3 would include breaking changes (edit - sorry, I just noticed that is the first thing in the upgrade guide).

Is there a way to retain the non-AJAX table functionality? Ideally something like $this->crud->disableAjaxTable(); . Keeping AJAX as the default, but allowing for non-AJAX as well.

I know this has been a huge effort to get rid of all the issues with AJAX tables, and it has been very successful, but there is some functionality that is simply not possible with AJAX that was removed in this latest update. I haven't been able to properly search a number of tables in my app and will likely need to revert to 3.2 so they are usable again. I feel like we lost some functionality for the sake of a luxury change.

tabacitu commented 7 years ago

Hi @jsiebach ,

Ugh... pretty tricky, this one.

But you should be able to keep the 3.2 non-AJAX functionality in your project, if you want to:

  1. We've removed all non-AJAX functionality in list.blade.php and the filters folder. So theoretically you could publish those from CRUD 3.2, and Backpack will pick them up instead of the ones in vendor.
  2. There's no disableAjaxTable() method. I though of inserting it but it made little sense - enableAjaxTabe() is marked as deprecated, so this disable method would be inserted already deprecated :-) But you can do this manually in your EntityCrudController::setup():
    $this->crud->ajax_table = false;

These two changes should allow you to use the old non-AJAX functionality. Hope it helps.

But I do think there should be ways to simulate the DataTables JS search in Eloquent. I've found very very little use cases where it isn't possible, and in most cases I think it's worth giving a little something away (making a column non-searchable, or not perfectly searchable), in order to have the same simple code working in all CRUDs, and be able to update the package... My 2 cents...

Cheers!

karandatwani92 commented 6 years ago

$this->crud->ajax_table = false;

Nothing changed using this. ajax is still enabled.