Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 从shinyincubator自定义matrixInput函数以删除+;/-并显示列名_Html_Css_R_Shiny - Fatal编程技术网

Html 从shinyincubator自定义matrixInput函数以删除+;/-并显示列名

Html 从shinyincubator自定义matrixInput函数以删除+;/-并显示列名,html,css,r,shiny,Html,Css,R,Shiny,以下是指向matrixInput函数代码链接的链接 属于shinyIncubator包装。 我有两个问题,与代码的css/html部分有关;这是一种我一无所知的语言。 以下是一个简单的可复制示例: 服务器.R shinyServer(函数(输入、输出){}) 用户界面 库(“闪亮”) 图书馆(“shinyIncubator”) df大家好,问题的读者们 因为我迫切需要答案,所以我花了一些时间自己随机尝试,laso试图从相关主题中获得灵感。 我想我有一个功能,可以正确地完成我现在想要的事情。 我

以下是指向
matrixInput
函数代码链接的链接 属于
shinyIncubator
包装。 我有两个问题,与代码的css/html部分有关;这是一种我一无所知的语言。 以下是一个简单的可复制示例:

服务器.R

shinyServer(函数(输入、输出){})

用户界面

库(“闪亮”)
图书馆(“shinyIncubator”)

df大家好,问题的读者们

因为我迫切需要答案,所以我花了一些时间自己随机尝试,laso试图从相关主题中获得灵感。 我想我有一个功能,可以正确地完成我现在想要的事情。 我将在这里发布代码

基本上它和原作是一样的,但是有一些东西我通过把它们作为评论来禁用,你会看到的

matrixInput2 <- function(inputId, label, data) {
  addResourcePath(
    prefix='tableinput', 
    directoryPath=system.file('tableinput', 
                              package='shinyIncubator'))

  tagList(
    singleton(
      tags$head(
        tags$link(rel = 'stylesheet',
                  type = 'text/css',
                  href = 'tableinput/tableinput.css'),
        tags$script(src = 'tableinput/tableinput.js')
      )
    ),

    tags$div(
      class = 'control-group tableinput-container',
      tags$label(
        class = "control-label",
        label
        #THIS seems to be responsible (atleast partially, regarding the display) for the +/- buttons
        # ,
        # tags$div(
        #   class = 'tableinput-buttons',
        #   tags$button(
        #     type = 'button', class = 'btn btn-mini tableinput-settings hide',
        #     tags$i(class = 'glyphicon glyphicon-cog icon-cog')
        #   ),
        #   HTML('<a href="#" class="tableinput-plusrow"><i class="glyphicon glyphicon-plus-sign icon-plus-sign"></i></a>'),
        #   HTML('<a href="#" class="tableinput-minusrow"><i class="glyphicon glyphicon-minus-sign icon-minus-sign"></i></a>')
        # )
      ),
      tags$table(
        id = inputId,
        class = 'tableinput data table table-bordered table-condensed',
        tags$colgroup(
          lapply(names(data), function(name) {
            tags$col('data-name' = name,
                     'data-field' = name,
                     'data-type' = 'numeric')
          })
        )
        ,
        tags$thead(
          #Here I just put this line as a comment. Setting the class as 'hide' hid the column names. I don't know where the deal with the rownames is.
          # class = 'hide',
          tags$tr(
            lapply(names(data), function(name) {
              tags$th(name)
            })
          )
        ),
        tags$tbody(
          lapply(1:nrow(data), function(i) {
            tags$tr(
              lapply(names(data), function(name) {
                tags$td(
                  div(tabindex=0, as.character(data[i,name]))
                )
              })
            )
          })
        )
      ),
      tags$div(
        class = 'tableinput-editor modal hide fade',
        tags$div(
          class = 'modal-header',
          HTML('<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>'),
          tags$h3(label)
        ),
        tags$div(
          class = 'modal-body',

          HTML('
               <form class="form-horizontal">
               <div class="control-group">
               <label class="control-label">Rows</label>
               <div class="controls">
               <input type="number" class="tableinput-rowcount">
               </div>
               </div>
               <div class="control-group">
               <label class="control-label">Columns</label>
               <div class="controls">
               <input type="number" class="tableinput-colcount">
               </div>
               </div>
               </form>'
          )
          ),
        tags$div(
          class = 'modal-footer',
          tags$a(href = '#', class = 'btn btn-primary tableinput-edit', 'OK'),
          tags$a(href = '#',
                 class = 'btn',
                 'data-dismiss' = 'modal',
                 'aria-hidden' = 'true',
                 'Cancel')
        )
          )
      )
    )
}

matrixInput2如果有人发现这个修改过的函数有bug,请在这里发布,我们将尝试解决它
matrixInput2 <- function(inputId, label, data) {
  addResourcePath(
    prefix='tableinput', 
    directoryPath=system.file('tableinput', 
                              package='shinyIncubator'))

  tagList(
    singleton(
      tags$head(
        tags$link(rel = 'stylesheet',
                  type = 'text/css',
                  href = 'tableinput/tableinput.css'),
        tags$script(src = 'tableinput/tableinput.js')
      )
    ),

    tags$div(
      class = 'control-group tableinput-container',
      tags$label(
        class = "control-label",
        label
        #THIS seems to be responsible (atleast partially, regarding the display) for the +/- buttons
        # ,
        # tags$div(
        #   class = 'tableinput-buttons',
        #   tags$button(
        #     type = 'button', class = 'btn btn-mini tableinput-settings hide',
        #     tags$i(class = 'glyphicon glyphicon-cog icon-cog')
        #   ),
        #   HTML('<a href="#" class="tableinput-plusrow"><i class="glyphicon glyphicon-plus-sign icon-plus-sign"></i></a>'),
        #   HTML('<a href="#" class="tableinput-minusrow"><i class="glyphicon glyphicon-minus-sign icon-minus-sign"></i></a>')
        # )
      ),
      tags$table(
        id = inputId,
        class = 'tableinput data table table-bordered table-condensed',
        tags$colgroup(
          lapply(names(data), function(name) {
            tags$col('data-name' = name,
                     'data-field' = name,
                     'data-type' = 'numeric')
          })
        )
        ,
        tags$thead(
          #Here I just put this line as a comment. Setting the class as 'hide' hid the column names. I don't know where the deal with the rownames is.
          # class = 'hide',
          tags$tr(
            lapply(names(data), function(name) {
              tags$th(name)
            })
          )
        ),
        tags$tbody(
          lapply(1:nrow(data), function(i) {
            tags$tr(
              lapply(names(data), function(name) {
                tags$td(
                  div(tabindex=0, as.character(data[i,name]))
                )
              })
            )
          })
        )
      ),
      tags$div(
        class = 'tableinput-editor modal hide fade',
        tags$div(
          class = 'modal-header',
          HTML('<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>'),
          tags$h3(label)
        ),
        tags$div(
          class = 'modal-body',

          HTML('
               <form class="form-horizontal">
               <div class="control-group">
               <label class="control-label">Rows</label>
               <div class="controls">
               <input type="number" class="tableinput-rowcount">
               </div>
               </div>
               <div class="control-group">
               <label class="control-label">Columns</label>
               <div class="controls">
               <input type="number" class="tableinput-colcount">
               </div>
               </div>
               </form>'
          )
          ),
        tags$div(
          class = 'modal-footer',
          tags$a(href = '#', class = 'btn btn-primary tableinput-edit', 'OK'),
          tags$a(href = '#',
                 class = 'btn',
                 'data-dismiss' = 'modal',
                 'aria-hidden' = 'true',
                 'Cancel')
        )
          )
      )
    )
}