Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use differrent Datatable option in R/Shiny ? #1148

Open
yoelii opened this issue Aug 19, 2024 · 4 comments
Open

How to use differrent Datatable option in R/Shiny ? #1148

yoelii opened this issue Aug 19, 2024 · 4 comments

Comments

@yoelii
Copy link

yoelii commented Aug 19, 2024

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

@stla
Copy link
Collaborator

stla commented Aug 19, 2024

The option name is dom. On the datatables.net website, the documentation is given for version 2, while the R package DT uses version 1.

@yoelii
Copy link
Author

yoelii commented Aug 19, 2024

Yes, but It's work well for change location of pagination with modification in CSS style
How I can change button by icon for example ?

@stla
Copy link
Collaborator

stla commented Aug 19, 2024

Please next time use StackOverflow for such a question. I wrote this question for you and I answered it: https://stackoverflow.com/q/78889329/1100107.

The Github issues are rather used to report some bugs or to request some features.

@yoelii
Copy link
Author

yoelii commented Aug 20, 2024

Thanks you for your answer in StackOverflow.
I ask my question in github page because I think to the possibility to use icon extensions from DataTabel ( https://datatables.net/extensions/buttons/examples/styling/icons.html) or default icon for pagination link in zero_configuration (https://datatables.net/examples/basic_init/zero_configuration.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants