Examples for 'htmlTable::interactiveTable'


An interactive table that allows you to limit the size of boxes

Aliases: interactiveTable interactiveTable.htmlTable knit_print.interactiveTable print.interactiveTable

Keywords:

### ** Examples

library(magrittr)
# A simple output
long_txt <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit
in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum"
short_txt <- gsub("(^[^.]+).*", "\\1", long_txt)

cbind(rep(short_txt, 2),
      rep(long_txt, 2)) %>%
  addHtmlTableStyle(col.rgroup = c("#FFF", "#EEF")) %>%
  interactiveTable(minimized.columns = ncol(.),
                   header = c("Short", "Long"),
                   rnames = c("First", "Second"))
Short Long
First Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Lorem ipsum dolor si...
Second Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Lorem ipsum dolor si...
$(document).ready(function(){ $(".gmisc_table td .hidden").map(function(index, el){ el.parentNode.style["original-color"] = el.parentNode.style["background-color"]; el.parentNode.style["background-color"] = "#DDD"; }); getSelected = function(){ var t = ''; if(window.getSelection){ t = window.getSelection(); }else if(document.getSelection){ t = document.getSelection(); }else if(document.selection){ t = document.selection.createRange().text; } return t.toString(); }; $(".gmisc_table td").map(function(index, el){ this.style.cursor = "pointer"; el.onmouseup = function(e){ if (getSelected().length > 0) return; var hidden = this.getElementsByClassName("hidden"); if (hidden.length > 0){ this.innerHTML = hidden[0].textContent; this.style["background-color"] = this.style["original-color"]; }else{ $(this).append(""); this.childNodes[0].data = this.childNodes[0].data.substr(0, 20) + "... "; this.style["original-color"] = this.style["background-color"]; this.style["background-color"] = "#DDD"; } }; }); });

[Package htmlTable version 2.4.3 Index]