Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show blank_slate when all records filtered out #275

Open
linesarefuzzy opened this issue Feb 11, 2016 · 3 comments
Open

Show blank_slate when all records filtered out #275

linesarefuzzy opened this issue Feb 11, 2016 · 3 comments

Comments

@linesarefuzzy
Copy link

The blank_slate feature only works when there are no records in the database. I would like it to also show the blank slate when no records are returned due to filters—at least when using detached filters. I realize this behavior is documented in the readme, but I don't see its value. If this is considered a feature, perhaps it could be an option.

@leikind
Copy link
Owner

leikind commented Feb 12, 2016

i am currently not working on this plugin. But this should be a simple feature/configuration. Look at line

   if rendering.blank_slate_handler && grid.resultset.size == 0 && !grid.filtering_on?

in wice_grid_view_helpers.rb

Running or not running the last check will do the trick.

I will accept a pull request.

@linesarefuzzy
Copy link
Author

Thanks for the tip! I actually found that on my own and tried disabling the last boolean. It does show the blank slate instead of the grid, but it also makes all the filters disappear. I tried to investigate further into the filter generation, but I wasn't able to figure it out.

As a workaround, is it possible to determine from the grid instance whether the filtered result set is empty? I tried empty?, size, count, do_count, resultset.size, resultset.count, even resultset_without_paging_with_user_filters—all return > 0 even when the table is empty.

@rockorequin
Copy link

If there are no records, you could display the grid title row and filters as well as the text "No records found" by looking for this in wice_grid_view_helpers.rb#grid_html:

grid.output_buffer << '</tfoot><tbody>'

and inserting this line immediately after it:

grid.output_buffer << "<tr><td colspan='#{rendering.number_of_columns + (no_rightmost_column ? 0 : 1)}'>No records found</td></tr>" if grid.resultset.length == 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants