Try using the following script
Problem
with this approach is, it won't work in views with grouping. The
problem is, on grouping, collapsed group data is not rendered on page
load. To tackle this we need to tweak scripts in INIT.js, but directly
modifying is not a good practice. To overcome this we can override the
method which is rendering the data as shown in the below script block.
To use this script, edit the page -> add a content editor webpart.