DataTables and render

526 views
Skip to first unread message

Lisa Zorn

unread,
Oct 8, 2014, 5:24:26 PM10/8/14
to shiny-...@googlegroups.com
Hi -

I'd like to be able to render numbers from my data table (commas, percentages, decimals, etc).

I am using renderDataTable()

It seems like I should be doing this via the columns.render: https://datatables.net/reference/option/columns.render

I can get javascript to get called but I'm not sure what to pass for "data" and "targets" -- I keep getting errors when I try.

For example, when I try with the following options:

  }, options = list("paging"=FALSE,      # no paging
                   
"searching"=FALSE,   # no search/filter boxes
                   
"columnDefs"= list(list("className"="alignRight",
                                           
"targets"=list(2,3,4,5,6,7)),
                                       list
("type"="num-fmt",
                                           
"targets"=list(2,3,4,5,6,7)),
                                       list
("render"="function(data,type,full,meta) { console.log('hi'); console.log(data); console.log(type); console.log(full); console.log(meta); return '123';}",
                                           
"targets"=list(2,3))
                                       
)
                   
)
 
)


I get this error:

DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter '2' for row 0. For more information about this error, please see http://datatables.net/tn/4


Has anyone gotten render to work?

Thanks,
-Lisa

Yihui Xie

unread,
Jan 2, 2015, 11:03:59 PM1/2/15
to Lisa Zorn, shiny-discuss
You may use the new package DT to solve this problem now. See the
section "Format Columns": http://rstudio.github.io/DT/

Regards,
Yihui
Reply all
Reply to author
Forward
0 new messages