简体   繁体   中英

rails fixed header table with varied width

I'm trying to create a fixed header table in my index view. After 2 days I'm on it, I finally found the jQuery fixedheadertable addon, and I still can't use it. I guess I'm doing something wrong because it's the first time I'm using jQuery. This is what I have done:

Added the file jquery.fixedheadertable.js to \\app\\assets\\javascripts

In application.js :

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require jquery.fixedheadertable
..
..

In my_js_coffee_file :

$ -> 
    $("#id_of_my_index_table").fixheadertable({
             caption : 'My header is fixed !',
             height  : 200
    });

Also tried:

$ ->
  $('#id_of_my_index_table').fixedHeaderTable('show');

No change at all... what's wrong here?

Thanks.

Your question does not have the details to properly analyse what is wrong. However, try these and see if it helps.

Does your application.js have require_tree in it? Also, try adding your my_js_coffee_file in the end of the application.js

Ex :

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require jquery.fixedheadertable
//= require my_js_coffee_file

Or alternatively, you can also code the same thing inside the application.js file itself. And then try running. Check your console log to see what errors pop up.

Using stickyTableHeaders JQuery plugin solved my problem.

https://github.com/jmosbech/StickyTableHeaders

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM