我试图让左边的总计对主面板中的数据表的变化做出React,但没有任何运气弄清楚如何以及在哪里插入代码来做到这一点。目前它们只在应用程序启动时呈现。
这里是显示它们的函数的部分代码。应用程序顶部
sumDebit <- function(){debitresult <- dbGetQuery(pool,"SELECT sum(debit) as tdebits FROM po.katpay ")
return(debitresult)
}
sumCredit <- function(){creditresult <- dbGetQuery(pool,"SELECT sum(credit) as tcredits FROM po.katpay ")
return(creditresult)
}
totBalance <- function(){sumDebit() - sumCredit()}
sidebarPanel2 <- function (..., out1 = NULL,out2=NULL,out3=NULL,out4=NULL, width = 18)
{
div(class = paste0("col-sm-", width),
tags$form(class = "well", ...),out1,out2,out3,out4
)
}
UI部分
ui <- fluidPage(
# Application title
titlePanel("Payment Editor"),
shinyjs::useShinyjs(),
shinyjs::inlineCSS(appCSS),
fluidRow(
actionButton("add_button", "Add", icon("plus")),
actionButton("edit_button", "Edit", icon("edit")),
actionButton("delete_button", "Delete", icon("trash-alt")),
actionButton("refresh_button", "Refresh", icon("refresh"))
),
# Sidebar
sidebarLayout(
sidebarPanel(width = 2,
selectInput(
inputId = "group_dims",
label = "Filter",
choices = c("date", "debit", "credit","company", "note"),
selected = c("None"),
multiple = TRUE
),
sidebarPanel2(fluid = TRUE,
out1 = h5("Total Debits = " , formatC(sumDebit(),format="d",big.mark=',')),
out2 = h5("Total Credits = ", formatC(sumCredit(),format="d",big.mark=',')),
#out3 = tags$hr(style="color:black"),
out4 = h5("Balance = ",formatC(totBalance(),format="d",big.mark=',')),
),
),
# DT table
mainPanel(DT::dataTableOutput("responses_table") %>% shinycssloaders::withSpinner()),
)
)# end fluidpage
添加/编辑/删除功能/按钮都工作正常,但我坚持如何使sidebarpanel2中的值更新的变化。如果我添加代码在服务器部分,我得到错误的用户界面,即找不到符号等。所以我想我不是真正理解如何用户界面和服务器是互动或什么标签,定义等,以传递他们之间,如果这是有意义的?
我试过使函数本身React没有运气...得到必须在一个React容器错误
我的猜测是大多数函数需要在服务器部分,我只需要在用户界面部分的字段值来填充,但我也不知道如何做到这一点。
- 不包括服务器代码,因为此时它对此没有任何作用。
1条答案
按热度按时间mspsb9vt1#
所以对于下一个家伙...或者提醒我在路上,我以为闪亮会很容易做的事情,结果需要一些JS和HTML来做。
这里的关键是div/classes和id,以便能够选择元素......我认为......基本理解这实际上只是一个客户机/服务器Web应用程序。
最上面的部分...
...在UI部分JS中处理服务器响应...
然后...
...以及服务器部分
由于某种原因,submit和submit_edit也可以工作,但没有为它们编写代码??这里有很多浪费的周期和多余的查询。。在我看来,但它很有效。
仅供参考,这是well2html在客户端的最终外观。
在shiny类"well"输入选择容器内