googleVis:多级排序功能gvisTable sortColumn? [英] googleVis: multi-level sorting feature gvisTable sortColumn?

查看:105
本文介绍了googleVis:多级排序功能gvisTable sortColumn?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在googleVis的gvisTable中进行多级排序? 我正在使用Shiny显示这样的gvisTable:

Is there a way to do multi-level sorting in a gvisTable in googleVis? I am using Shiny to display a gvisTable like this:

x <- gvisTable(tabData,options=list(sortColumn=2,showRowNumber='TRUE',allowHtml='TRUE'),chartid=tabID)

我想知道是否有一种方法可以对值进行排序,例如,首先按第2列,然后按第3列.

I am wondering if there is a way to sort the values, say, first by column 2 then by column 3.

如果gvisTable不具有此功能,但是googleVis之外的其他程序包中还有另一种类型的表可以在Shiny中完成,那也可以. 有什么想法吗?

If gvisTable does not have this feature but there is another type of table from another package other than googleVis that can do it in Shiny, that would be fine as well. Any ideas?

推荐答案

install.packages('shiny', type = 'source')

ui.r:

library(shiny)
shinyUI(bootstrapPage(
  dataTableOutput('tbl')
))

server.r:

library(shiny)
shinyServer(function(input, output) {
  output$tbl <- renderDataTable({
    data.frame(x = 1:10, y = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))
  })
})

从dataTables描述: http://datatables.net/examples/basic_init/multi_col_sort.html

From the dataTables description: http://datatables.net/examples/basic_init/multi_col_sort.html

如果bSort初始化程序为true(默认情况下),则这种多重排序机制始终处于活动状态,并且最终用户可以通过移位"单击要添加到排序的列来激活它."

"This multiple sorting mechanism is always active if the bSort initialiser is true (it is by default) and the end user can activate it by 'shift' clicking on the column they want to add to the sort."

因此,当您运行此应用程序时,请尝试按"y"进行排序,然后按住Shift键并单击x(观看列标题中的紫色突出显示的箭头),以查看"y"列保持排序状态,而"x列会更改排序顺序,而y保持不变.

Thus, when you run this application, try sorting by "y" and then shift-clicking x (watch the purple-highlighted arrows in the column heading), to see that the "y" column remains sorted, while the "x" column changes the sort-order leaving y fixed.

这篇关于googleVis:多级排序功能gvisTable sortColumn?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆