问题描述
我正在尝试使用在DataTables中找到的一些扩展选项为Shiny中的DataTable添加一个选项。
我要实现Opetion SearchBuilder.columns,以便搜索框只能在“ id”列中进行搜索 https://datatables.net/reference/option/searchBuilder.columns
如何在R Shiny中实现此选项?语法是什么?
下面的代码不起作用。
.item-inner {
height: 100vh;
background-size: 100% auto;
background-repeat: no-repeat;
background-position: center center;
transition: all 6.2s linear;
overflow: hidden;
}
.carousel-item.active .item-inner {
transition: all 6.2s linear;
background-size: 110% auto;
}
这是完整的代码:
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<div id="zoomer" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" id="activeOnLoad"> <!-- get the ID -->
<div class="item-inner" style="background-image: url('https://i.picsum.photos/id/874/1920/1680.jpg?hmac=KDczwg-ejraLUmoflMNUBCkt1LyLxNreJptc7RQajFY')"></div>
</div>
<div class="carousel-item">
<div class="item-inner" style="background-image: url('https://i.picsum.photos/id/878/1920/1680.jpg?hmac=_FQShv6E5HdjI6OKgjozFJQz8SXlT1OwmqijW5jHGQo')"></div>
</div>
<div class="carousel-item">
<div class="item-inner" style="background-image: url('https://i.picsum.photos/id/870/1920/1680.jpg?hmac=IAkVJX2zYS6BuaMLixYh5xoyOpeDH5WkcGTacBUppxM')"></div>
</div>
</div>
<a class="carousel-control-prev" href="#zoomer" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
</a>
<a class="carousel-control-next" href="#zoomer" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
</a>
</div>
解决方法
真棒扩展!
在“ DT”包中不可用。这是使用方法。
首先,下载the JavaScript file and the CSS file。
然后,这是R代码:
library(DT)
library(htmltools)
dat <- data.frame(
x = c(0,1,2,3,4),id = c("sub0","sub0","sub1","sub2")
)
dtable <- datatable(
dat,options = list(
dom = "Qlfrtip",searchBuilder = list(
columns = list(2) # 2 is the index of the 'id' column
)
)
)
path_to_searchBuilder <- # path to the folder containing the two searchBuilder files
normalizePath("~/Work/R/DT/searchBuilder/")
dep <- htmlDependency(
name = "searchBuilder",version = "1.0.0",src = path_to_searchBuilder,script = "dataTables.searchBuilder.min.js",stylesheet = "searchBuilder.dataTables.min.css",all_files = FALSE
)
dtable$dependencies <- c(dtable$dependencies,list(dep))
dtable