trk_datatables 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6bbcc94c87611e1aaa08588c6599df2c691192850905da3b981a69d908ffb981
4
- data.tar.gz: ac998b4e62500caf9be81419909a8c1d530f64c7737330c0fd4de22a40a082df
3
+ metadata.gz: 520b6d86f27312cd4c8bb89e62943f542be727954446ce8c4be03790727f7a4d
4
+ data.tar.gz: dd881cc122ffd0cbec3eca16db24ed65cfc98921d22080920d8df167a8c7260c
5
5
  SHA512:
6
- metadata.gz: 2adca44aac667b274f31b374f2914a9499f2c37294ef3d308ac45fd0fd0da26e0545093d62c508d42b5c78638e181e10b1c1f3b252396c0ca8a5a952a54dd509
7
- data.tar.gz: c1b6ab154c81408296714795d68521135da81bb0ca5226b9407c600f824cc566333f1f022cbd088d71629be94d83494ab2c94d41d71c178a2034e94b697288fd
6
+ metadata.gz: f7f62cc8d55ca17597c9c65d3aaf646f16f92a94873b97c83847e6e01f843f951ec74796e8064ed81cab802a404599006b3a7c321ecb672fc909c9f5e669724c
7
+ data.tar.gz: 27ea4d1cf61af80539f66502256a173c603416030da3943947fcf5d43eaefd068fe0112a7fa0d87aa2cca493f77b759c76f3c151afd1ecd3d85c44b1804e7216
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trk_datatables (0.2.8)
4
+ trk_datatables (0.2.9)
5
5
  activesupport
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -552,6 +552,24 @@ class PostsDatatable
552
552
  end
553
553
  ```
554
554
 
555
+ ### Render html with additional css class and different DOM
556
+
557
+ To add additional styling to your datatable you can use `:class` option when you
558
+ are calling `@datatable.render_html url, options` for example
559
+
560
+ ```
561
+ <%= @datatable.render_html search_posts_path(format: :json), class: 'table-hover' %>
562
+ ```
563
+
564
+ Default [DOM](https://datatables.net/reference/option/dom) is
565
+ `<"trk-global-search-wrapper"f>rtp<"trk-move-up"il>` which includes global
566
+ **f**iltering, p**r**ocessing loader, **t**able search, **p**agination, table
567
+ **i**nformation and **l**ength changing control. To override you can use
568
+
569
+ ```
570
+ <%= @datatable.render_html search_posts_path(format: :json), 'data-datatable-dom': 'rt' %>
571
+ ```
572
+
555
573
  ### Params
556
574
 
557
575
  To set parameters that you can use for links to set column search value, use
@@ -599,7 +617,7 @@ For global search you can use `[search][value]` for example
599
617
  If you need, you can fetch params with this helper
600
618
 
601
619
  ```
602
- PostsDatatable.param_get('users.email', params)
620
+ datatable.param_get 'users.email'
603
621
  ```
604
622
 
605
623
  You can set filters on datatable even params are blank, for example
@@ -117,7 +117,7 @@ module TrkDatatables
117
117
  def param_get(column_index)
118
118
  @params.dig :columns, column_index.to_s, :search, :value
119
119
  rescue TypeError => e
120
- raise Error, e.message + '. Column search is in a format: { "columns": { "0": { "search": { "value": { "ABC" } } } } }'
120
+ raise Error, "#{e.message}. Column search is in a format: { \"columns\": { \"0\": { \"search\": { \"value\": { \"ABC\" } } } } }"
121
121
  end
122
122
 
123
123
  def self.sample_view_params(options = {})
@@ -4,7 +4,7 @@ module TrkDatatables
4
4
  def initialize(search_link, datatable, html_options = {})
5
5
  @search_link = search_link
6
6
  @datatable = datatable
7
- @html_options = html_options
7
+ @html_options = html_options.symbolize_keys
8
8
  self.class.indent = 0
9
9
  end
10
10
 
@@ -89,6 +89,7 @@ module TrkDatatables
89
89
  # for initial page load we do not have ability to show recordsTotal
90
90
  # https://github.com/trkin/trk_datatables_js/issues/1
91
91
  'data-datatable-total-length': @datatable.filtered_items_count,
92
+ 'data-datatable-dom': @html_options[:'data-datatable-dom'] || '<"trk-global-search-wrapper"f>rtp<"trk-move-up"il>',
92
93
  ) do
93
94
  thead << "\n".html_safe << tbody
94
95
  end +
@@ -1,3 +1,3 @@
1
1
  module TrkDatatables
2
- VERSION = '0.2.8'.freeze
2
+ VERSION = '0.2.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trk_datatables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dusan Orlovic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-22 00:00:00.000000000 Z
11
+ date: 2021-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport