How can I set DataTables row callbacks in a Shiny R application?

Viewed 2099

In rCharts, one can set JS callbacks of DataTables using a special string notation: #! function(par) {...} !#. For example, let's look into the following R code:

  #JS callback to truncate long strings in table cells and add a tooltip
  callback = "#! 
  function (nRow) {
        $('td', nRow).each(function (index) {
            var maxChars = 80;
                var unfilteredText = $(this).text();
                if (unfilteredText.length > maxChars && maxChars > 3) {
                    $(this).attr('title', unfilteredText);
                    $(this).html(unfilteredText.substring(0, maxChars-4) + '...');
                }
        });
        return nRow;
    } !#"

  result <- dTable(df, aaSorting = list(c(5, "desc")), sPaginationType="full_numbers",
               fnRowCallback=callback)

Is this possible in Shiny DataTables?

1 Answers
Related