bogdan / datagrid

Gem to create tables grids with sortable columns and filters
MIT License
1.02k stars 115 forks source link

Little style issue #266

Closed dux closed 5 years ago

dux commented 5 years ago

this works as expected

      column :created_at do |model|
        model[:created_at].strftime('%d.%m.%y. %H:%M')
      end

but this fails with ArgumentError, and I think it should not. why do we need to provide col name if value is calculated?

      column do |model|
        model[:created_at].strftime('%d.%m.%y. %H:%M')
      end
bogdan commented 5 years ago

That is required if you work with columns in an advanced way and reference columns directly. Like assign a CSS stye. However you are right that it is not required for simple use cases. I need to think about that.

bogdan commented 5 years ago

I think it doesn't worth to support unnamed columns because you would need a header anyway and there is so high probability you would need a name for a column for direct reference down the road.

dux commented 5 years ago

if no header provided then no header name. if no col name then no sorting options.

I generate click buttons directly on the grid, last col on the left, and do not want to have a header and sorting options. is that possible?

bogdan commented 5 years ago

You can do

class Grid
  self.default_column_options = {order: false, header: ""}
end

Hiding header in the UI requires to change built-in partials https://github.com/bogdan/datagrid/wiki/Frontend#modifying-built-in-partials