Interfacing DataTables

Yihui Xie, RStudio

2016/01/31 @ Shiny Developer Conference

DataTables

A JavaScript library for interaction with HTML tables http://datatables.net

Basic usage (in JavaScript):

// this returns a DataTables API instance
$('#foo').DataTable({
  pageLength: 5,
  autoWidth: true
})

HTML Widgets

HTMLWidgets.widget({

  name: "FOO",

  type: "output",

  initialize: function(el, width, height) {
    // initialize the element
  },

  renderValue: function(el, data, instance) {
    // render the data in el, e.g.
    // $(el).DataTable(data.options);
  }

})

DT

Shiny (server-side processing)

Implementation of basic features

Pass info from DataTables to Shiny

Examples

Manipulate a DataTables instance

Recap

Oh, that is pretty cool…

from the user’s perspective

Yeah, it is this cool…

from the developer’s perspective

JavaScript indexes from 0!

Thanks!