How to use differrent Datatable option in R/Shiny ?

Open
#1,148 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, r

Research direction

Start with the datatable() options shown in the issue, especially extensions='Buttons', dom, buttons, and layout, then compare them with the linked DataTables Buttons styling example. Done means explaining or documenting how R/Shiny users position pagination and configure copy, print, and other button icons.

Written by the indexing model from the issue text.

Description

Hi,
I want to customize my DT by modify several options existing DataTable document. But I don't well understand how I can modify in R/shiny .

For example, I want to change the location of pagination, add icon for copy or print button, ...

On datatable pages, I found this kind of information :

new DataTable('#example', {
    layout: {
        topStart: {
            buttons: [
                {
                    extend: 'copyHtml5',
                    text: '<i class="fa fa-files-o"></i>',
                    titleAttr: 'Copy'
                },
                {
                    extend: 'excelHtml5',
                    text: '<i class="fa fa-file-excel-o"></i>',
                    titleAttr: 'Excel'
                },
                {
                    extend: 'csvHtml5',
                    text: '<i class="fa fa-file-text-o"></i>',
                    titleAttr: 'CSV'
                },
                {
                    extend: 'pdfHtml5',
                    text: '<i class="fa fa-file-pdf-o"></i>',
                    titleAttr: 'PDF'
                }
            ]
        }
    }
});

https://datatables.net/extensions/buttons/examples/styling/icons.html

When I try in R, it's not work.

datatable(
          mydata,
          extensions = 'Buttons',
          options = list(
            dom = '<"top"fpB>t<"bottom"il>',
            buttons = c('copy', 'csv', 'pdf', 'print'),
            searchHighlight = TRUE
          )
        )

I modify, not easily the location of element by dom option by not layout

datatable(
          parameters_ui$results,
          extensions = 'Buttons',
          options = list(
            dom = '<"top"fpB>t<"bottom"il>',
            buttons = c('copy', 'csv', 'pdf', 'print'),
          )
        )
datatable(
          my_data,
          options = list(
               layout = list(topstart = 'paging', bottomEnd = NULL)
          )
        )

Thanks in advance for your help

Dominant language
JavaScript
Stars
621
Forks
177
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/DT

All issues in rstudio/DT

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.