活动记录数据表中的静态过滤选项

Static filtering options in active record datatable

有人可以举一些静态过滤选项的例子吗?

我还需要知道在 (start_date > 2019-11-19) 的情况下 count_options 方法的返回格式是什么,这将如何在哈希中返回?

https://github.com/anikolskiy/datatables_crud/blob/bootstrap_3_simple_form_rails_5/lib/datatables_crud/datatables/active_record_datatable.rb#L32

count_options是这里定义的方法https://github.com/anikolskiy/datatables_crud/blob/bootstrap_3_simple_form_rails_5/lib/datatables_crud/datatables/active_record_datatable.rb#L32

它在内部用于过滤掉limitoffset选项。这些选项用于获取特定页面的结果(例如,10 页中的第 3 页)。获取总行数时,不应使用 limitoffset

至于具体的例子。 @options 可以是:

{
  conditions: "start_date > '2019-11-19'",
  limit:      20,
  offset:     60,
  order:      'name ASC'
}

... 并且 count_options 将 return:

{
  conditions: "start_date > '2019-11-19'",
  order:      'name ASC'
}

order in count_options 是无关紧要的,但也没有破坏任何东西。

@options 的另一个可能的(也是更常见的)示例是:

{
  conditions: { some_parent_object_id: 123 },
  limit:      20,
  offset:     120,
  order:      'start_date ASC'
}

和对应的count_options:

{
  conditions: { some_parent_object_id: 123 },
  order:      'start_date ASC'
}