Code Monkey home page Code Monkey logo

tabletastic's Introduction

Tabletastic 使用

table_for

example:

table_for @admin_users, html: { class: '' } do |t|
  ...
end
  • 配置 Tabletastic.default_table_html 来指定 table 的默认样式

cell

example:

table_for @admin_users do |t|
  t.cell(:login, width: '20%', sort: true, cell_html: { }, heading_html: {}) { |user| user.great_login }
end
  • width: 指定 head 的宽度,对应于 th 里面的 width
  • cell_html: 指定 tbody 里面 td 的样式
  • heading_html: 指定 thead 里面 td 的样式
  • sort: 集成类似于 ransack 的 sort_link,传递 {"q": {"s": "login asc"}} 参数
  • block: 替换掉默认显示的内容 user.login

操作

对于 actions 采用 block 的形式

<%= t.cell(:action) do |user| %>
  <%= render_edit_link(user) %>
  <%= render_block_user_link(user) %>
<% end %>

已知的 Bug

<%= t.cell(:comments_count) { |q| q.comments.count } %>

这样会显示不出结果,要改成

<%= t.cell(:comments_count) { |q| q.comments.count.to_s } %>

tabletastic's People

Contributors

jgdavey avatar zlx avatar hashrocketeer avatar balinterdi avatar

Stargazers

 avatar Haimeng Zhou avatar Ken Lu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.