DevanB / datatables-rails-bs3

datatables bootstrap 3 for rails
https://rubygems.org/gems/datatables-rails-bs3
Other
2 stars 1 forks source link

Sortable Arrow Images Not Showing #3

Open bbtfr opened 9 years ago

bbtfr commented 9 years ago

I use datatables-rails-bs3 with my Rails 4 project, and I got an exception in production mode.

GET http://www.pandacourse.com/assets/datatables/sort_asc.png 404 (Not Found) admin-e14a70de3039aadeed15c39473a436ad.js:2
GET http://www.pandacourse.com/assets/datatables/sort_both.png 404 (Not Found) admin-e14a70de3039aadeed15c39473a436ad.js:2

In admin.js there are just 2 lines.

//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap

And I have added admin.js to Rails.application.config.assets.precompile

Rails.application.config.assets.precompile += %w( html5shiv.min.js respond.min.js admin.js )

Now, to fix this, I have to add following lines to my css file:

table.table thead .sorting { background: image-url('datatables/sort_both.png') no-repeat center right; }
table.table thead .sorting_asc { background: image-url('datatables/sort_asc.png') no-repeat center right; }
table.table thead .sorting_desc { background: image-url('datatables/sort_desc.png') no-repeat center right; }

table.table thead .sorting_asc_disabled { background: image-url('datatables/sort_asc_disabled.png') no-repeat center right; }
table.table thead .sorting_desc_disabled { background: image-url('datatables/sort_desc_disabled.png') no-repeat center right; }

Use image-url instead of url, and add all image filenames to precompile

Rails.application.config.assets.precompile += %w( html5shiv.min.js respond.min.js admin.js 
  datatables/sort_both.png datatables/sort_asc.png datatables/sort_desc.png 
  datatables/sort_asc_disabled.png datatables/sort_desc_disabled.png )

It works.

But I think it's better to be done in your engine file.

avinashl3175 commented 7 years ago

Sorting arrow visible only after on click of individual table header. Please suggest some solution.

DevanB commented 7 years ago

Woah, it's been a while!

I'll try updating the gem to solve @bbtfr's problem.

While I'm doing that, I'll look into your problem @avinashl3175.

Thanks for using the gem. Give me a few days to fix it, and I'll respond here after the new version is published!

-dev