7

I have a new rails install. I followed the instructions on this page exactly: https://github.com/rweng/jquery-datatables-rails

When I try to view a datatable, I get these errors:

GET http://localhost:3000/images/sort_both.png 404 (Not Found)
GET http://localhost:3000/images/sort_asc.png 404 (Not Found)

In config/environments/development.rb I've tried changing the following settings:

config.assets.debug = false #and also tried true
config.serve_static_assets = true #and also tried false
config.assets.enabled = true

I've also tried running rake assets:precompile

Not sure what I'm missing here. Any help would be greatly appreciated.

6 Answers 6

25

Perhaps someone will present a better answer. This is how I fixed it.

I got rid of the gem. Downloaded the javascript and css files from the datatables website:

Put these files in vendor/assets/stylesheets and vendor/assets/javascripts respectively.

I downloaded the missing images from here and stuck them in my vendor/assets/images folder that I created.

I did a replace all on the text in jquery.dataTables.min.css and replaced "/images/" with "/assets/"

And that fixed it. Hope this helps someone.

Sign up to request clarification or add additional context in comments.

2 Comments

This is pretty much exactly what I was thinking.
I change vendor/assets/stylesheets/plugins/dataTables.bootstrap.css Replace 'background: url('../images/sort_desc_disabled.png') no-repeat center right;' with 'background: url('/assets/images/sort_desc_disabled.png') no-repeat center right;'
1

1. Download Image From Here :

https://cdnjs.com/libraries/datatables

enter image description here

2. create datatable folder inside assets and put images inside it

enter image description here

3. in your style.scss or style.css add below code :

table.dataTable thead .sorting {
    background-image: url("./assets/datatable/sort_both.png");
}

table.dataTable thead .sorting_asc {
    background-image: url("./assets/datatable/sort_asc.png") !important;
}

table.dataTable thead .sorting_desc {
    background-image: url("./assets/datatable/sort_desc.png") !important;
}

table.dataTable thead .sorting_asc_disabled {
    background-image: url("./assets/datatable/sort_asc_disabled.png");
}

table.dataTable thead .sorting_desc_disabled {
    background-image: url("./assets/datatable/sort_desc_disabled.png");
}

Comments

0

I had the same problem and fixed it using a different version of the jquery.dataTables.min.css file, where the images are written as strings rather than as references to a file.

Comments

0

For me it worked just by changing the below:

background:url('../images/sort_desc.png')
background:url('../images/sort_asc.png')

to

background:url('/assets/sort_desc.png')
background:url('/assets/sort_asc.png')

NOTE: please make sure you add the images to assets/images folder

Comments

0

i can find one more solution just add 2 pure white background .png imgaes in images folder of ui solution and save it as

sort_both.png ans sort_asc.png

basically this images are set the background to header of datatable

Comments

0

I had same problem and this is what I settled with

<style>
    table.dataTable thead .sorting {
        background: url("/Content/DataTables/images/sort_both.png") no-repeat center right;
         } 
    table.dataTable thead .sorting_asc {
        background: url("/Content/DataTables/images/sort_asc.png") no-repeat center right;
        }
    table.dataTable thead .sorting_desc {
        background: url("/Content/DataTables/images/sort_desc.png") no-repeat center right;
       }
</style>

It just a quick fix without changing any thing in the supplied files. Dont forget to change
[ /Content/DataTables/images/ ]
accordingly

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.