在我进行编辑后,焦点所在的行跳到了#1行,这破坏了用户体验
我已经尝试过回答诸如R Shiny - multi-page editable DataTable jumps to row #1 after an edit
之类的问题有我的服务器
server <- function(input, output, session) {
x = reactiveValues(df = NULL)
observe({
plus <-eventReactive(input$detail,{
df <- plus() #its a dataframe who comes from a mysql query
df=cbind(matrix(0,nrow(df),1), matrix(0,nrow(df),1),df)
colnames(df)=c("a","b","Imagen","Referencia","Nombre",
"Unidad de Medida","Cantidad Real","Cantidad Solicitada"
,"Precio")
x$df <- df
})
output[["table"]] <- DT::renderDataTable({
df3=x$df
DT::datatable(
isolate(df3),
class = 'cell-border stripe',
extensions = 'Buttons',
options = list(dom = 'Bfrtip',
buttons = c('copy','excel'),pageLength = nrow(df3),scrollX = T),
selection=list(mode="single", target="row"),
rownames=FALSE,
filter = 'top',escape = FALSE,editable = TRUE)
})
proxy = dataTableProxy('table')
observeEvent(input$table_cell_edit, {
info = input$table_cell_edit
str(info)
i = info$row
j = info$col
v = info$value
# problem starts here
proxy = dataTableProxy('table')
x$df[i, j+1] <- isolate(DT::coerceValue(v, x$df[i, j]))
replaceData(proxy, x$df,resetPaging = F)
})
}
我希望当我在dt中编辑某些单元格时,不会跳到第1行