flexdashboard icon indicating copy to clipboard operation
flexdashboard copied to clipboard

Add df_print: paged ?

Open vnijs opened this issue 8 years ago • 5 comments

It seems the df_print: paged option is not available for a flexdashboard. Could this feature be added?

vnijs avatar May 12 '17 21:05 vnijs

That's a great idea (paged tables weren't available when we developed flexdashboard but they are a perfect fit). I may even make them the default.

Should be able to get this in over the next couple of weeks.

jjallaire avatar May 13 '17 00:05 jjallaire

As it turns out paged tables "just work" in flexdashboard however their sizing behavior isn't idea. this code will embed a paged table:

rmarkdown::paged_table(df)

However that results in:

screen shot 2017-05-17 at 8 47 17 am

What we ideally want is a paged table that will automatically adapt to changes in height (currently it adapts to changes in width, not sure if height works yet) and perhaps also without the border (as we already have a border).

@javierluraschi In flexdashboard we can register custom JavaScript code to run in order to "adapt" content to work well in flexdashboard (we currently do this for DT and knitr::kable) so all we would need are JavaScript APIs on the paged table to get it to do the right thing. Let me know what you think.

jjallaire avatar May 17 '17 12:05 jjallaire

@javierluraschi Here is some initial work I've done on handling paged tables: https://github.com/rstudio/flexdashboard/pull/124

It's mostly CSS tweaks right now, in the "layout" function I get a handle to the paged table but don't yet quite know what to do with it to make it adapt itself to fit available height (looking at it's source code it appears as if it does indeed know how to do this)

jjallaire avatar May 17 '17 13:05 jjallaire

@jjallaire sorry to be catching up late on this, your change looks good!

In general, paged tables don't care about the width nor height, it's the responsibility of the host to set those correctly so your change to set this to width: 100% makes a lot of sense. All the paged table does is to look at its width/height and figure out how many columns/rows it can fit, if it can't, it adds paging on either side. Paged tables listen to window resize events and reformat themselves; however, if something else triggers the resize, they wouldn't know. That said, we could add functionality with a timer to track the width/height of the paged table and retrigger a render() call whenever this happens or the host could manually trigger pagedTable.resize(<width>, <height>) which is what the IDE currently does today.

BTW. There is an overlap between <int> and <dbl>, I think this just got fixed with the cut off fixed from the PR: https://github.com/rstudio/rmarkdown/pull/1056

javierluraschi avatar May 25 '17 17:05 javierluraschi

Okay, I am going to hold off on this for right now b/c as it stands these tables would only work for static flexdashboards and wouldn't work with shiny based flexdashboards. To do the latter we'd need either a paged table html widget or some custom paged table shiny output handlers defined within the flexdashboard package.

jjallaire avatar May 25 '17 18:05 jjallaire