亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 JS 增加 Shiny DT 表中搜索框的大小

使用 JS 增加 Shiny DT 表中搜索框的大小

慕哥6287543 2022-07-21 10:44:41
繼這篇文章之后。在下面的示例中,如何在 JS 調用中增加搜索框的大???我想將搜索框的大小增加到當前長度的 4 倍?是否有可能實現這種場景?library(shiny)library(DT)callback <- 'var x = document.createElement("INPUT");x.setAttribute("type", "text");x.setAttribute("id", "mySearch");x.setAttribute("placeholder", "Search");x.style.float = "right";$("div.search").append($(x));$("#mySearch").on("keyup redraw", function(){  var splits = $("#mySearch").val().split(" ").filter(function(x){return x !=="";})  var searchString = "(" + splits.join("|") + ")";  table.search(searchString, true).draw(true);});'ui <- fluidPage(  DTOutput("dtable"))server <- function(input, output){  output[["dtable"]] <- renderDT({    datatable(      iris[c(1,2,51,52,101,102),],      options = list(        dom = "l<'search'>rtip"      ),      callback = JS(callback)    )  }, server = FALSE)}shinyApp(ui, server)會話信息:R version 3.6.3 (2020-02-29)Platform: x86_64-apple-darwin15.6.0 (64-bit)Running under: macOS High Sierra 10.13.6Matrix products: defaultBLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylibLAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dyliblocale:[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8attached base packages:[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods  [9] base     other attached packages: [1] ggplot2_3.3.0        DT_0.13              rsconnect_0.8.16     shinythemes_1.1.2    [5] dplyr_0.8.5          shiny_1.4.0.2        BiocParallel_1.20.1  MLInterfaces_1.66.5  [9] cluster_2.1.0        annotate_1.64.0      XML_3.99-0.3         AnnotationDbi_1.48.0[13] IRanges_2.20.2       MSnbase_2.12.0       ProtGenerics_1.18.0  S4Vectors_0.24.4    [17] mzR_2.20.0           Rcpp_1.0.4.6         Biobase_2.46.0       BiocGenerics_0.32.0 
查看完整描述

1 回答

?
冉冉說

TA貢獻1877條經驗 獲得超1個贊

感謝您的意見。

確實x.style.width = "50%";callback(之后x.style.float)工作。


查看完整回答
反對 回復 2022-07-21
  • 1 回答
  • 0 關注
  • 94 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號